
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>常用的前端JavaScript方法封装 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="异步神器Async-await介绍与填坑.html" />
    
    
    <link rel="prev" href="在 JavaScript 中交换值的 10 种方法.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >常用的前端JavaScript方法封装</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;javascript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;"><b>1. </b>&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;JavaScript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;</a></li></ul></div><a href="#&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;javascript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;javascript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;"><a name="&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;javascript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;javascript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x5E38;&#x7528;&#x7684;&#x524D;&#x7AEF;JavaScript&#x65B9;&#x6CD5;&#x5C01;&#x88C5;</h1>
<p>[TOC]</p>
<h5 id="1&#x3001;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x8FD4;&#x56DE;&#x5176;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="1&#x3001;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x8FD4;&#x56DE;&#x5176;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#1&#x3001;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x8FD4;&#x56DE;&#x5176;&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>1&#x3001;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x8FD4;&#x56DE;&#x5176;&#x6570;&#x636E;&#x7C7B;&#x578B;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">type</span>(<span class="hljs-params">para</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Object</span>.prototype.toString.call(para)
}
</code></pre>
<h5 id="2&#x3001;&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><a name="2&#x3001;&#x6570;&#x7EC4;&#x53BB;&#x91CD;" class="anchor-navigation-ex-anchor" href="#2&#x3001;&#x6570;&#x7EC4;&#x53BB;&#x91CD;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>2&#x3001;&#x6570;&#x7EC4;&#x53BB;&#x91CD;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">unique1</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">return</span> [...new <span class="hljs-built_in">Set</span>(arr)]
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">unique2</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">var</span> obj = {};
    <span class="hljs-keyword">return</span> arr.filter(<span class="hljs-function"><span class="hljs-params">ele</span> =&gt;</span> {
        <span class="hljs-keyword">if</span> (!obj[ele]) {
            obj[ele] = <span class="hljs-literal">true</span>;
            <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
        }
    })
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">unique3</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">var</span> result = [];
    arr.forEach(<span class="hljs-function"><span class="hljs-params">ele</span> =&gt;</span> {
        <span class="hljs-keyword">if</span> (result.indexOf(ele) == <span class="hljs-number">-1</span>) {
            result.push(ele)
        }
    })
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h5 id="3&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53BB;&#x91CD;"><a name="3&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53BB;&#x91CD;" class="anchor-navigation-ex-anchor" href="#3&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53BB;&#x91CD;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>3&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x53BB;&#x91CD;</strong></h5>
<pre><code class="lang-javascript">String.prototype.unique = function () {
    var obj = {},
        str = &apos;&apos;,
        len = this.length;
    for (var i = 0; i &lt; len; i++) {
        if (!obj[this[i]]) {
            str += this[i];
            obj[this[i]] = true;
        }
    }
    return str;
}

###### //&#x53BB;&#x9664;&#x8FDE;&#x7EED;&#x7684;&#x5B57;&#x7B26;&#x4E32; 
function uniq(str) {
    return str.replace(/(\w)\1+/g, &apos;$1&apos;)
}
</code></pre>
<h5 id="4&#x3001;&#x6DF1;&#x62F7;&#x8D1D;-&#x6D45;&#x62F7;&#x8D1D;"><a name="4&#x3001;&#x6DF1;&#x62F7;&#x8D1D;-&#x6D45;&#x62F7;&#x8D1D;" class="anchor-navigation-ex-anchor" href="#4&#x3001;&#x6DF1;&#x62F7;&#x8D1D;-&#x6D45;&#x62F7;&#x8D1D;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>4&#x3001;&#x6DF1;&#x62F7;&#x8D1D; &#x6D45;&#x62F7;&#x8D1D;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-comment">//&#x6DF1;&#x514B;&#x9686;&#xFF08;&#x6DF1;&#x514B;&#x9686;&#x4E0D;&#x8003;&#x8651;&#x51FD;&#x6570;&#xFF09;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deepClone</span>(<span class="hljs-params">obj, result</span>) </span>{
    <span class="hljs-keyword">var</span> result = result || {};
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> obj) {
        <span class="hljs-keyword">if</span> (obj.hasOwnProperty(prop)) {
            <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> obj[prop] == <span class="hljs-string">&apos;object&apos;</span> &amp;&amp; obj[prop] !== <span class="hljs-literal">null</span>) {
                <span class="hljs-comment">// &#x5F15;&#x7528;&#x503C;(obj/array)&#x4E14;&#x4E0D;&#x4E3A;null</span>
                <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>.prototype.toString.call(obj[prop]) == <span class="hljs-string">&apos;[object Object]&apos;</span>) {
                    <span class="hljs-comment">// &#x5BF9;&#x8C61;</span>
                    result[prop] = {};
                } <span class="hljs-keyword">else</span> {
                    <span class="hljs-comment">// &#x6570;&#x7EC4;</span>
                    result[prop] = [];
                }
                deepClone(obj[prop], result[prop])
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-comment">// &#x539F;&#x59CB;&#x503C;&#x6216;func</span>
        result[prop] = obj[prop]
    }
  }
}
<span class="hljs-keyword">return</span> result;
}

<span class="hljs-comment">// &#x6DF1;&#x6D45;&#x514B;&#x9686;&#x662F;&#x9488;&#x5BF9;&#x5F15;&#x7528;&#x503C;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deepClone</span>(<span class="hljs-params">target</span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> (target) !== <span class="hljs-string">&apos;object&apos;</span>) {
        <span class="hljs-keyword">return</span> target;
    }
    <span class="hljs-keyword">var</span> result;
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>.prototype.toString.call(target) == <span class="hljs-string">&apos;[object Array]&apos;</span>) {
        <span class="hljs-comment">// &#x6570;&#x7EC4;</span>
        result = []
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-comment">// &#x5BF9;&#x8C61;</span>
        result = {};
    }
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> target) {
        <span class="hljs-keyword">if</span> (target.hasOwnProperty(prop)) {
            result[prop] = deepClone(target[prop])
        }
    }
    <span class="hljs-keyword">return</span> result;
}
<span class="hljs-comment">// &#x65E0;&#x6CD5;&#x590D;&#x5236;&#x51FD;&#x6570;</span>
<span class="hljs-keyword">var</span> o1 = jsON.parse(jsON.stringify(obj1));
</code></pre>
<h5 id="5&#x3001;reverse&#x5E95;&#x5C42;&#x539F;&#x7406;&#x548C;&#x6269;&#x5C55;"><a name="5&#x3001;reverse&#x5E95;&#x5C42;&#x539F;&#x7406;&#x548C;&#x6269;&#x5C55;" class="anchor-navigation-ex-anchor" href="#5&#x3001;reverse&#x5E95;&#x5C42;&#x539F;&#x7406;&#x548C;&#x6269;&#x5C55;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>5&#x3001;reverse&#x5E95;&#x5C42;&#x539F;&#x7406;&#x548C;&#x6269;&#x5C55;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x6539;&#x53D8;&#x539F;&#x6570;&#x7EC4;</span>
<span class="hljs-built_in">Array</span>.prototype.myReverse = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        <span class="hljs-keyword">var</span> temp = <span class="hljs-keyword">this</span>[i];
        <span class="hljs-keyword">this</span>[i] = <span class="hljs-keyword">this</span>[len - <span class="hljs-number">1</span> - i];
        <span class="hljs-keyword">this</span>[len - <span class="hljs-number">1</span> - i] = temp;
    }
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
}
</code></pre>
<h5 id="6&#x3001;&#x5723;&#x676F;&#x6A21;&#x5F0F;&#x7684;&#x7EE7;&#x627F;"><a name="6&#x3001;&#x5723;&#x676F;&#x6A21;&#x5F0F;&#x7684;&#x7EE7;&#x627F;" class="anchor-navigation-ex-anchor" href="#6&#x3001;&#x5723;&#x676F;&#x6A21;&#x5F0F;&#x7684;&#x7EE7;&#x627F;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>6&#x3001;&#x5723;&#x676F;&#x6A21;&#x5F0F;&#x7684;&#x7EE7;&#x627F;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">inherit</span>(<span class="hljs-params">Target, Origin</span>) </span>{
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">F</span>(<span class="hljs-params"></span>) </span>{};
    F.prototype = Origin.prototype;
    Target.prototype = <span class="hljs-keyword">new</span> F();
    Target.prototype.constructor = Target;
    <span class="hljs-comment">// &#x6700;&#x7EC8;&#x7684;&#x539F;&#x578B;&#x6307;&#x5411;</span>
    Target.prop.uber = Origin.prototype;
}
</code></pre>
<h5 id="7&#x3001;&#x627E;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7B2C;&#x4E00;&#x6B21;&#x53EA;&#x51FA;&#x73B0;&#x4E00;&#x6B21;&#x7684;&#x5B57;&#x6BCD;"><a name="7&#x3001;&#x627E;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7B2C;&#x4E00;&#x6B21;&#x53EA;&#x51FA;&#x73B0;&#x4E00;&#x6B21;&#x7684;&#x5B57;&#x6BCD;" class="anchor-navigation-ex-anchor" href="#7&#x3001;&#x627E;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7B2C;&#x4E00;&#x6B21;&#x53EA;&#x51FA;&#x73B0;&#x4E00;&#x6B21;&#x7684;&#x5B57;&#x6BCD;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>7&#x3001;&#x627E;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7B2C;&#x4E00;&#x6B21;&#x53EA;&#x51FA;&#x73B0;&#x4E00;&#x6B21;&#x7684;&#x5B57;&#x6BCD;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">String</span>.prototype.firstAppear = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> obj = {},
        len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        <span class="hljs-keyword">if</span> (obj[<span class="hljs-keyword">this</span>[i]]) {
            obj[<span class="hljs-keyword">this</span>[i]]++;
        } <span class="hljs-keyword">else</span> {
            obj[<span class="hljs-keyword">this</span>[i]] = <span class="hljs-number">1</span>;
        }
    }
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> obj) {
       <span class="hljs-keyword">if</span> (obj[prop] == <span class="hljs-number">1</span>) {
         <span class="hljs-keyword">return</span> prop;
       }
    }
}
</code></pre>
<h5 id="8&#x3001;&#x627E;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x7EA7;&#x7236;&#x5143;&#x7D20;"><a name="8&#x3001;&#x627E;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x7EA7;&#x7236;&#x5143;&#x7D20;" class="anchor-navigation-ex-anchor" href="#8&#x3001;&#x627E;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x7EA7;&#x7236;&#x5143;&#x7D20;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>8&#x3001;&#x627E;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x7EA7;&#x7236;&#x5143;&#x7D20;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">parents</span>(<span class="hljs-params">ele, n</span>) </span>{
    <span class="hljs-keyword">while</span> (ele &amp;&amp; n) {
        ele = ele.parentElement ? ele.parentElement : ele.parentNode;
        n--;
    }
    <span class="hljs-keyword">return</span> ele;
}
</code></pre>
<h5 id="9&#x3001;-&#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5144;&#x5F1F;&#x8282;&#x70B9;"><a name="9&#x3001;-&#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5144;&#x5F1F;&#x8282;&#x70B9;" class="anchor-navigation-ex-anchor" href="#9&#x3001;-&#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5144;&#x5F1F;&#x8282;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>9&#x3001; &#x8FD4;&#x56DE;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5144;&#x5F1F;&#x8282;&#x70B9;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">retSibling</span>(<span class="hljs-params">e, n</span>) </span>{
    <span class="hljs-keyword">while</span> (e &amp;&amp; n) {
        <span class="hljs-keyword">if</span> (n &gt; <span class="hljs-number">0</span>) {
            <span class="hljs-keyword">if</span> (e.nextElementSibling) {
                e = e.nextElementSibling;
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-keyword">for</span> (e = e.nextSibling; e &amp;&amp; e.nodeType !== <span class="hljs-number">1</span>; e = e.nextSibling);
            }
            n--;
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-keyword">if</span> (e.previousElementSibling) {
                e = e.previousElementSibling;
            } <span class="hljs-keyword">else</span> {
                <span class="hljs-keyword">for</span> (e = e.previousElementSibling; e &amp;&amp; e.nodeType !== <span class="hljs-number">1</span>; e = e.previousElementSibling);
            }
            n++;
        }
    }
    <span class="hljs-keyword">return</span> e;
}
</code></pre>
<h5 id="10&#x3001;&#x5C01;&#x88C5;mychildren&#xFF0C;&#x89E3;&#x51B3;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x517C;&#x5BB9;&#x95EE;&#x9898;"><a name="10&#x3001;&#x5C01;&#x88C5;mychildren&#xFF0C;&#x89E3;&#x51B3;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x517C;&#x5BB9;&#x95EE;&#x9898;" class="anchor-navigation-ex-anchor" href="#10&#x3001;&#x5C01;&#x88C5;mychildren&#xFF0C;&#x89E3;&#x51B3;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x517C;&#x5BB9;&#x95EE;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>10&#x3001;&#x5C01;&#x88C5;mychildren&#xFF0C;&#x89E3;&#x51B3;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x517C;&#x5BB9;&#x95EE;&#x9898;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myChildren</span>(<span class="hljs-params">e</span>) </span>{
    <span class="hljs-keyword">var</span> children = e.childNodes,
        arr = [],
        len = children.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        <span class="hljs-keyword">if</span> (children[i].nodeType === <span class="hljs-number">1</span>) {
            arr.push(children[i])
        }
    }
    <span class="hljs-keyword">return</span> arr;
}
</code></pre>
<h5 id="11&#x3001;&#x5224;&#x65AD;&#x5143;&#x7D20;&#x6709;&#x6CA1;&#x6709;&#x5B50;&#x5143;&#x7D20;"><a name="11&#x3001;&#x5224;&#x65AD;&#x5143;&#x7D20;&#x6709;&#x6CA1;&#x6709;&#x5B50;&#x5143;&#x7D20;" class="anchor-navigation-ex-anchor" href="#11&#x3001;&#x5224;&#x65AD;&#x5143;&#x7D20;&#x6709;&#x6CA1;&#x6709;&#x5B50;&#x5143;&#x7D20;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>11&#x3001;&#x5224;&#x65AD;&#x5143;&#x7D20;&#x6709;&#x6CA1;&#x6709;&#x5B50;&#x5143;&#x7D20;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">hasChildren</span>(<span class="hljs-params">e</span>) </span>{
    <span class="hljs-keyword">var</span> children = e.childNodes,
        len = children.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        <span class="hljs-keyword">if</span> (children[i].nodeType === <span class="hljs-number">1</span>) {
            <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
        }
    }
    <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
}
</code></pre>
<h5 id="12&#x3001;&#x6211;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63D2;&#x5165;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x540E;&#x9762;"><a name="12&#x3001;&#x6211;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63D2;&#x5165;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x540E;&#x9762;" class="anchor-navigation-ex-anchor" href="#12&#x3001;&#x6211;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63D2;&#x5165;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x540E;&#x9762;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>12&#x3001;&#x6211;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63D2;&#x5165;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x540E;&#x9762;</strong></h5>
<pre><code class="lang-javascript">Element.prototype.insertAfter = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">target, elen</span>) </span>{
    <span class="hljs-keyword">var</span> nextElen = elen.nextElenmentSibling;
    <span class="hljs-keyword">if</span> (nextElen == <span class="hljs-literal">null</span>) {
        <span class="hljs-keyword">this</span>.appendChild(target);
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">this</span>.insertBefore(target, nextElen);
    }
}
</code></pre>
<h5 id="13&#x3001;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x65F6;&#x95F4;&#xFF08;&#x5E74;&#x6708;&#x65E5;&#x65F6;&#x5206;&#x79D2;&#xFF09;"><a name="13&#x3001;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x65F6;&#x95F4;&#xFF08;&#x5E74;&#x6708;&#x65E5;&#x65F6;&#x5206;&#x79D2;&#xFF09;" class="anchor-navigation-ex-anchor" href="#13&#x3001;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x65F6;&#x95F4;&#xFF08;&#x5E74;&#x6708;&#x65E5;&#x65F6;&#x5206;&#x79D2;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>13&#x3001;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x65F6;&#x95F4;&#xFF08;&#x5E74;&#x6708;&#x65E5;&#x65F6;&#x5206;&#x79D2;&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getDateTime</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(),
        year = date.getFullYear(),
        month = date.getMonth() + <span class="hljs-number">1</span>,
        day = date.getDate(),
        hour = date.getHours() + <span class="hljs-number">1</span>,
        minute = date.getMinutes(),
        second = date.getSeconds();
        month = checkTime(month);
        day = checkTime(day);
        hour = checkTime(hour);
        minute = checkTime(minute);
        second = checkTime(second);
     <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">checkTime</span>(<span class="hljs-params">i</span>) </span>{
        <span class="hljs-keyword">if</span> (i &lt; <span class="hljs-number">10</span>) {
                i = <span class="hljs-string">&quot;0&quot;</span> + i;
       }
      <span class="hljs-keyword">return</span> i;
    }
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;&quot;</span> + year + <span class="hljs-string">&quot;&#x5E74;&quot;</span> + month + <span class="hljs-string">&quot;&#x6708;&quot;</span> + day + <span class="hljs-string">&quot;&#x65E5;&quot;</span> + hour + <span class="hljs-string">&quot;&#x65F6;&quot;</span> + minute + <span class="hljs-string">&quot;&#x5206;&quot;</span> + second + <span class="hljs-string">&quot;&#x79D2;&quot;</span>
}
</code></pre>
<h5 id="14&#x3001;&#x83B7;&#x5F97;&#x6EDA;&#x52A8;&#x6761;&#x7684;&#x6EDA;&#x52A8;&#x8DDD;&#x79BB;"><a name="14&#x3001;&#x83B7;&#x5F97;&#x6EDA;&#x52A8;&#x6761;&#x7684;&#x6EDA;&#x52A8;&#x8DDD;&#x79BB;" class="anchor-navigation-ex-anchor" href="#14&#x3001;&#x83B7;&#x5F97;&#x6EDA;&#x52A8;&#x6761;&#x7684;&#x6EDA;&#x52A8;&#x8DDD;&#x79BB;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>14&#x3001;&#x83B7;&#x5F97;&#x6EDA;&#x52A8;&#x6761;&#x7684;&#x6EDA;&#x52A8;&#x8DDD;&#x79BB;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getScrollOffset</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.pageXOffset) {
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">x</span>: <span class="hljs-built_in">window</span>.pageXOffset,
            <span class="hljs-attr">y</span>: <span class="hljs-built_in">window</span>.pageYOffset
        }
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">x</span>: <span class="hljs-built_in">document</span>.body.scrollLeft + <span class="hljs-built_in">document</span>.documentElement.scrollLeft,
            <span class="hljs-attr">y</span>: <span class="hljs-built_in">document</span>.body.scrollTop + <span class="hljs-built_in">document</span>.documentElement.scrollTop
        }
    }
}
</code></pre>
<h5 id="15&#x3001;&#x83B7;&#x5F97;&#x89C6;&#x53E3;&#x7684;&#x5C3A;&#x5BF8;"><a name="15&#x3001;&#x83B7;&#x5F97;&#x89C6;&#x53E3;&#x7684;&#x5C3A;&#x5BF8;" class="anchor-navigation-ex-anchor" href="#15&#x3001;&#x83B7;&#x5F97;&#x89C6;&#x53E3;&#x7684;&#x5C3A;&#x5BF8;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>15&#x3001;&#x83B7;&#x5F97;&#x89C6;&#x53E3;&#x7684;&#x5C3A;&#x5BF8;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getViewportOffset</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.innerWidth) {
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">w</span>: <span class="hljs-built_in">window</span>.innerWidth,
            <span class="hljs-attr">h</span>: <span class="hljs-built_in">window</span>.innerHeight
        }
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-comment">// ie8&#x53CA;&#x5176;&#x4EE5;&#x4E0B;</span>
        <span class="hljs-keyword">if</span> (<span class="hljs-built_in">document</span>.compatMode === <span class="hljs-string">&quot;BackCompat&quot;</span>) {
            <span class="hljs-comment">// &#x602A;&#x5F02;&#x6A21;&#x5F0F;</span>
            <span class="hljs-keyword">return</span> {
                <span class="hljs-attr">w</span>: <span class="hljs-built_in">document</span>.body.clientWidth,
                <span class="hljs-attr">h</span>: <span class="hljs-built_in">document</span>.body.clientHeight
            }
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// &#x6807;&#x51C6;&#x6A21;&#x5F0F;</span>
            <span class="hljs-keyword">return</span> {
                <span class="hljs-attr">w</span>: <span class="hljs-built_in">document</span>.documentElement.clientWidth,
                <span class="hljs-attr">h</span>: <span class="hljs-built_in">document</span>.documentElement.clientHeight
            }
        }
    }
}
</code></pre>
<h5 id="16&#x3001;&#x83B7;&#x53D6;&#x4EFB;&#x4E00;&#x5143;&#x7D20;&#x7684;&#x4EFB;&#x610F;&#x5C5E;&#x6027;"><a name="16&#x3001;&#x83B7;&#x53D6;&#x4EFB;&#x4E00;&#x5143;&#x7D20;&#x7684;&#x4EFB;&#x610F;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#16&#x3001;&#x83B7;&#x53D6;&#x4EFB;&#x4E00;&#x5143;&#x7D20;&#x7684;&#x4EFB;&#x610F;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>16&#x3001;&#x83B7;&#x53D6;&#x4EFB;&#x4E00;&#x5143;&#x7D20;&#x7684;&#x4EFB;&#x610F;&#x5C5E;&#x6027;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getStyle</span>(<span class="hljs-params">elem, prop</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">window</span>.getComputedStyle ? <span class="hljs-built_in">window</span>.getComputedStyle(elem, <span class="hljs-literal">null</span>)[prop] : elem.currentStyle[prop]
}
</code></pre>
<h5 id="17&#x3001;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;"><a name="17&#x3001;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#17&#x3001;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>17&#x3001;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addEvent</span>(<span class="hljs-params">elem, type, handle</span>) </span>{
    <span class="hljs-keyword">if</span> (elem.addEventListener) { <span class="hljs-comment">//&#x975E;ie&#x548C;&#x975E;ie9</span>
        elem.addEventListener(type, handle, <span class="hljs-literal">false</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (elem.attachEvent) { <span class="hljs-comment">//ie6&#x5230;ie8</span>
        elem.attachEvent(<span class="hljs-string">&apos;on&apos;</span> + type, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            handle.call(elem);
        })
    } <span class="hljs-keyword">else</span> {
        elem[<span class="hljs-string">&apos;on&apos;</span> + type] = handle;
    }
}
</code></pre>
<h5 id="18&#x3001;&#x89E3;&#x7ED1;&#x4E8B;&#x4EF6;"><a name="18&#x3001;&#x89E3;&#x7ED1;&#x4E8B;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#18&#x3001;&#x89E3;&#x7ED1;&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>18&#x3001;&#x89E3;&#x7ED1;&#x4E8B;&#x4EF6;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">removeEvent</span>(<span class="hljs-params">elem, type, handle</span>) </span>{
    <span class="hljs-keyword">if</span> (elem.removeEventListener) { <span class="hljs-comment">//&#x975E;ie&#x548C;&#x975E;ie9</span>
        elem.removeEventListener(type, handle, <span class="hljs-literal">false</span>);
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (elem.detachEvent) { <span class="hljs-comment">//ie6&#x5230;ie8</span>
        elem.detachEvent(<span class="hljs-string">&apos;on&apos;</span> + type, handle);
    } <span class="hljs-keyword">else</span> {
        elem[<span class="hljs-string">&apos;on&apos;</span> + type] = <span class="hljs-literal">null</span>;
    }
}
</code></pre>
<h5 id="19&#x3001;&#x53D6;&#x6D88;&#x5192;&#x6CE1;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;"><a name="19&#x3001;&#x53D6;&#x6D88;&#x5192;&#x6CE1;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#19&#x3001;&#x53D6;&#x6D88;&#x5192;&#x6CE1;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>19&#x3001;&#x53D6;&#x6D88;&#x5192;&#x6CE1;&#x7684;&#x517C;&#x5BB9;&#x4EE3;&#x7801;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">stopBubble</span>(<span class="hljs-params">e</span>) </span>{
    <span class="hljs-keyword">if</span> (e &amp;&amp; e.stopPropagation) {
        e.stopPropagation();
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">window</span>.event.cancelBubble = <span class="hljs-literal">true</span>;
    }
}
</code></pre>
<h5 id="20&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;"><a name="20&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;" class="anchor-navigation-ex-anchor" href="#20&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>20&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isPalina</span>(<span class="hljs-params">str</span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>.prototype.toString.call(str) !== <span class="hljs-string">&apos;[object String]&apos;</span>) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }
    <span class="hljs-keyword">var</span> len = str.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len / <span class="hljs-number">2</span>; i++) {
        <span class="hljs-keyword">if</span> (str[i] != str[len - <span class="hljs-number">1</span> - i]) {
            <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
        }
    }
    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
</code></pre>
<h5 id="21&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;"><a name="21&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;" class="anchor-navigation-ex-anchor" href="#21&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>21&#x3001;&#x68C0;&#x9A8C;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x662F;&#x56DE;&#x6587;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isPalindrome</span>(<span class="hljs-params">str</span>) </span>{
    str = str.replace(<span class="hljs-regexp">/\W/g</span>, <span class="hljs-string">&apos;&apos;</span>).toLowerCase();
    <span class="hljs-built_in">console</span>.log(str)
    <span class="hljs-keyword">return</span> (str == str.split(<span class="hljs-string">&apos;&apos;</span>).reverse().join(<span class="hljs-string">&apos;&apos;</span>))
}
</code></pre>
<h5 id="22&#x3001;&#x517C;&#x5BB9;getelementsbyclassname&#x65B9;&#x6CD5;"><a name="22&#x3001;&#x517C;&#x5BB9;getelementsbyclassname&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#22&#x3001;&#x517C;&#x5BB9;getelementsbyclassname&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>22&#x3001;&#x517C;&#x5BB9;getElementsByClassName&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript">Element.prototype.getElementsByClassName = Document.prototype.getElementsByClassName = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">_className</span>) </span>{
    <span class="hljs-keyword">var</span> allDomArray = <span class="hljs-built_in">document</span>.getElementsByTagName(<span class="hljs-string">&apos;*&apos;</span>);
    <span class="hljs-keyword">var</span> lastDomArray = [];
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">trimSpace</span>(<span class="hljs-params">strClass</span>) </span>{
        <span class="hljs-keyword">var</span> reg = <span class="hljs-regexp">/\s+/g</span>;
        <span class="hljs-keyword">return</span> strClass.replace(reg, <span class="hljs-string">&apos; &apos;</span>).trim()
    }
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; allDomArray.length; i++) {
        <span class="hljs-keyword">var</span> classArray = trimSpace(allDomArray[i].className).split(<span class="hljs-string">&apos; &apos;</span>);
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> j = <span class="hljs-number">0</span>; j &lt; classArray.length; j++) {
            <span class="hljs-keyword">if</span> (classArray[j] == _className) {
                lastDomArray.push(allDomArray[i]);
                <span class="hljs-keyword">break</span>;
            }
        }
    }
    <span class="hljs-keyword">return</span> lastDomArray;
}
</code></pre>
<h5 id="23&#x3001;&#x8FD0;&#x52A8;&#x51FD;&#x6570;"><a name="23&#x3001;&#x8FD0;&#x52A8;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#23&#x3001;&#x8FD0;&#x52A8;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>23&#x3001;&#x8FD0;&#x52A8;&#x51FD;&#x6570;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">animate</span>(<span class="hljs-params">obj, json, callback</span>) </span>{
    clearInterval(obj.timer);
    <span class="hljs-keyword">var</span> speed,
        current;
    obj.timer = setInterval(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">var</span> lock = <span class="hljs-literal">true</span>;
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> json) {
            <span class="hljs-keyword">if</span> (prop == <span class="hljs-string">&apos;opacity&apos;</span>) {
                current = <span class="hljs-built_in">parseFloat</span>(<span class="hljs-built_in">window</span>.getComputedStyle(obj, <span class="hljs-literal">null</span>)[prop]) * <span class="hljs-number">100</span>;
            } <span class="hljs-keyword">else</span> {
                current = <span class="hljs-built_in">parseInt</span>(<span class="hljs-built_in">window</span>.getComputedStyle(obj, <span class="hljs-literal">null</span>)[prop]);
            }
            speed = (json[prop] - current) / <span class="hljs-number">7</span>;
            speed = speed &gt; <span class="hljs-number">0</span> ? <span class="hljs-built_in">Math</span>.ceil(speed) : <span class="hljs-built_in">Math</span>.floor(speed);

            <span class="hljs-keyword">if</span> (prop == <span class="hljs-string">&apos;opacity&apos;</span>) {
                obj.style[prop] = (current + speed) / <span class="hljs-number">100</span>;
            } <span class="hljs-keyword">else</span> {
                obj.style[prop] = current + speed + <span class="hljs-string">&apos;px&apos;</span>;
            }
            <span class="hljs-keyword">if</span> (current != json[prop]) {
                lock = <span class="hljs-literal">false</span>;
            }
        }
        <span class="hljs-keyword">if</span> (lock) {
            clearInterval(obj.timer);
            <span class="hljs-keyword">typeof</span> callback == <span class="hljs-string">&apos;function&apos;</span> ? callback() : <span class="hljs-string">&apos;&apos;</span>;
        }
    }, <span class="hljs-number">30</span>)
}
</code></pre>
<h5 id="24&#x3001;&#x5F39;&#x6027;&#x8FD0;&#x52A8;"><a name="24&#x3001;&#x5F39;&#x6027;&#x8FD0;&#x52A8;" class="anchor-navigation-ex-anchor" href="#24&#x3001;&#x5F39;&#x6027;&#x8FD0;&#x52A8;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>24&#x3001;&#x5F39;&#x6027;&#x8FD0;&#x52A8;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ElasticMovement</span>(<span class="hljs-params">obj, target</span>) </span>{
    clearInterval(obj.timer);
    <span class="hljs-keyword">var</span> iSpeed = <span class="hljs-number">40</span>,
        a, u = <span class="hljs-number">0.8</span>;
    obj.timer = setInterval(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        a = (target - obj.offsetLeft) / <span class="hljs-number">8</span>;
        iSpeed = iSpeed + a;
        iSpeed = iSpeed * u;
        <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Math</span>.abs(iSpeed) &lt;= <span class="hljs-number">1</span> &amp;&amp; <span class="hljs-built_in">Math</span>.abs(a) &lt;= <span class="hljs-number">1</span>) {
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;over&apos;</span>)
            clearInterval(obj.timer);
            obj.style.left = target + <span class="hljs-string">&apos;px&apos;</span>;
        } <span class="hljs-keyword">else</span> {
            obj.style.left = obj.offsetLeft + iSpeed + <span class="hljs-string">&apos;px&apos;</span>;
        }
    }, <span class="hljs-number">30</span>);
}
</code></pre>
<h5 id="25&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;foreach&#x65B9;&#x6CD5;"><a name="25&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;foreach&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#25&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;foreach&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>25&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;forEach&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.prototype.myForEach = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">func, obj</span>) </span>{
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">var</span> _this = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>] ? <span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>] : <span class="hljs-built_in">window</span>;
    <span class="hljs-comment">// var _this=arguments[1]||window;</span>
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        func.call(_this, <span class="hljs-keyword">this</span>[i], i, <span class="hljs-keyword">this</span>)
    }
}
</code></pre>
<h5 id="26&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;filter&#x65B9;&#x6CD5;"><a name="26&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;filter&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#26&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;filter&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>26&#x3001;&#x5C01;&#x88C5;&#x81EA;&#x5DF1;&#x7684;filter&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.prototype.myFilter = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">func, obj</span>) </span>{
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">var</span> arr = [];
    <span class="hljs-keyword">var</span> _this = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>] || <span class="hljs-built_in">window</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        func.call(_this, <span class="hljs-keyword">this</span>[i], i, <span class="hljs-keyword">this</span>) &amp;&amp; arr.push(<span class="hljs-keyword">this</span>[i]);
    }
    <span class="hljs-keyword">return</span> arr;
}
</code></pre>
<h5 id="27&#x3001;&#x6570;&#x7EC4;map&#x65B9;&#x6CD5;"><a name="27&#x3001;&#x6570;&#x7EC4;map&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#27&#x3001;&#x6570;&#x7EC4;map&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>27&#x3001;&#x6570;&#x7EC4;map&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.prototype.myMap = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">func</span>) </span>{
    <span class="hljs-keyword">var</span> arr = [];
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">var</span> _this = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>] || <span class="hljs-built_in">window</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        arr.push(func.call(_this, <span class="hljs-keyword">this</span>[i], i, <span class="hljs-keyword">this</span>));
    }
    <span class="hljs-keyword">return</span> arr;
}
</code></pre>
<h5 id="28&#x3001;&#x6570;&#x7EC4;every&#x65B9;&#x6CD5;"><a name="28&#x3001;&#x6570;&#x7EC4;every&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#28&#x3001;&#x6570;&#x7EC4;every&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>28&#x3001;&#x6570;&#x7EC4;every&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.prototype.myEvery = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">func</span>) </span>{
    <span class="hljs-keyword">var</span> flag = <span class="hljs-literal">true</span>;
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length;
    <span class="hljs-keyword">var</span> _this = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>] || <span class="hljs-built_in">window</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len; i++) {
        <span class="hljs-keyword">if</span> (func.apply(_this, [<span class="hljs-keyword">this</span>[i], i, <span class="hljs-keyword">this</span>]) == <span class="hljs-literal">false</span>) {
            flag = <span class="hljs-literal">false</span>;
            <span class="hljs-keyword">break</span>;
        }
    }
    <span class="hljs-keyword">return</span> flag;
}
</code></pre>
<h5 id="29&#x3001;&#x6570;&#x7EC4;reduce&#x65B9;&#x6CD5;"><a name="29&#x3001;&#x6570;&#x7EC4;reduce&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#29&#x3001;&#x6570;&#x7EC4;reduce&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>29&#x3001;&#x6570;&#x7EC4;reduce&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.prototype.myReduce = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">func, initialValue</span>) </span>{
    <span class="hljs-keyword">var</span> len = <span class="hljs-keyword">this</span>.length,
        nextValue,
        i;
    <span class="hljs-keyword">if</span> (!initialValue) {
        <span class="hljs-comment">// &#x6CA1;&#x6709;&#x4F20;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;</span>
        nextValue = <span class="hljs-keyword">this</span>[<span class="hljs-number">0</span>];
        i = <span class="hljs-number">1</span>;
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-comment">// &#x4F20;&#x4E86;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;</span>
        nextValue = initialValue;
        i = <span class="hljs-number">0</span>;
    }
    <span class="hljs-keyword">for</span> (; i &lt; len; i++) {
        nextValue = func(nextValue, <span class="hljs-keyword">this</span>[i], i, <span class="hljs-keyword">this</span>);
    }
    <span class="hljs-keyword">return</span> nextValue;
}
</code></pre>
<h5 id="30&#x3001;&#x83B7;&#x53D6;url&#x4E2D;&#x7684;&#x53C2;&#x6570;&#xFF08;1&#xFF09;"><a name="30&#x3001;&#x83B7;&#x53D6;url&#x4E2D;&#x7684;&#x53C2;&#x6570;&#xFF08;1&#xFF09;" class="anchor-navigation-ex-anchor" href="#30&#x3001;&#x83B7;&#x53D6;url&#x4E2D;&#x7684;&#x53C2;&#x6570;&#xFF08;1&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>30&#x3001;&#x83B7;&#x53D6;url&#x4E2D;&#x7684;&#x53C2;&#x6570;&#xFF08;1&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getWindonHref</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> sHref = <span class="hljs-built_in">window</span>.location.href;
    <span class="hljs-keyword">var</span> args = sHref.split(<span class="hljs-string">&apos;?&apos;</span>);
    <span class="hljs-keyword">if</span> (args[<span class="hljs-number">0</span>] === sHref) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;&apos;</span>;
    }
    <span class="hljs-keyword">var</span> hrefarr = args[<span class="hljs-number">1</span>].split(<span class="hljs-string">&apos;#&apos;</span>)[<span class="hljs-number">0</span>].split(<span class="hljs-string">&apos;&amp;&apos;</span>);
    <span class="hljs-keyword">var</span> obj = {};
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; hrefarr.length; i++) {
        hrefarr[i] = hrefarr[i].split(<span class="hljs-string">&apos;=&apos;</span>);
        obj[hrefarr[i][<span class="hljs-number">0</span>]] = hrefarr[i][<span class="hljs-number">1</span>];
    }
    <span class="hljs-keyword">return</span> obj;
}
</code></pre>
<h5 id="31&#x3001;&#x6570;&#x7EC4;&#x6392;&#x5E8F;"><a name="31&#x3001;&#x6570;&#x7EC4;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#31&#x3001;&#x6570;&#x7EC4;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>31&#x3001;&#x6570;&#x7EC4;&#x6392;&#x5E8F;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x5FEB;&#x6392; [left] + min + [right]</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">quickArr</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">if</span> (arr.length &lt;= <span class="hljs-number">1</span>) {
        <span class="hljs-keyword">return</span> arr;
    }
    <span class="hljs-keyword">var</span> left = [],
        right = [];
    <span class="hljs-keyword">var</span> pIndex = <span class="hljs-built_in">Math</span>.floor(arr.length / <span class="hljs-number">2</span>);
    <span class="hljs-keyword">var</span> p = arr.splice(pIndex, <span class="hljs-number">1</span>)[<span class="hljs-number">0</span>];
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; arr.length; i++) {
        <span class="hljs-keyword">if</span> (arr[i] &lt;= p) {
            left.push(arr[i]);
        } <span class="hljs-keyword">else</span> {
            right.push(arr[i]);
        }
    }
    <span class="hljs-comment">// &#x9012;&#x5F52;</span>
    <span class="hljs-keyword">return</span> quickArr(left).concat([p], quickArr(right));
}

<span class="hljs-comment">// &#x5192;&#x6CE1;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">bubbleSort</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; arr.length - <span class="hljs-number">1</span>; i++) {
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> j = i + <span class="hljs-number">1</span>; j &lt; arr.length; j++) {
            <span class="hljs-keyword">if</span> (arr[i] &gt; arr[j]) {
                <span class="hljs-keyword">var</span> temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }
    <span class="hljs-keyword">return</span> arr;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">bubbleSort</span>(<span class="hljs-params">arr</span>) </span>{
    <span class="hljs-keyword">var</span> len = arr.length;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; len - <span class="hljs-number">1</span>; i++) {
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> j = <span class="hljs-number">0</span>; j &lt; len - <span class="hljs-number">1</span> - i; j++) {
            <span class="hljs-keyword">if</span> (arr[j] &gt; arr[j + <span class="hljs-number">1</span>]) {
                <span class="hljs-keyword">var</span> temp = arr[j];
                arr[j] = arr[j + <span class="hljs-number">1</span>];
                arr[j + <span class="hljs-number">1</span>] = temp;
            }
        }
    }
    <span class="hljs-keyword">return</span> arr;
}
</code></pre>
<h5 id="32&#x3001;&#x904D;&#x5386;dom&#x6811;"><a name="32&#x3001;&#x904D;&#x5386;dom&#x6811;" class="anchor-navigation-ex-anchor" href="#32&#x3001;&#x904D;&#x5386;dom&#x6811;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>32&#x3001;&#x904D;&#x5386;Dom&#x6811;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x7ED9;&#x5B9A;&#x9875;&#x9762;&#x4E0A;&#x7684;DOM&#x5143;&#x7D20;,&#x5C06;&#x8BBF;&#x95EE;&#x5143;&#x7D20;&#x672C;&#x8EAB;&#x53CA;&#x5176;&#x6240;&#x6709;&#x540E;&#x4EE3;(&#x4E0D;&#x4EC5;&#x4EC5;&#x662F;&#x5B83;&#x7684;&#x76F4;&#x63A5;&#x5B50;&#x5143;&#x7D20;)</span>
<span class="hljs-comment">// &#x5BF9;&#x4E8E;&#x6BCF;&#x4E2A;&#x8BBF;&#x95EE;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x51FD;&#x6570;&#x8BB2;&#x5143;&#x7D20;&#x4F20;&#x9012;&#x7ED9;&#x63D0;&#x4F9B;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">traverse</span>(<span class="hljs-params">element, callback</span>) </span>{
    callback(element);
    <span class="hljs-keyword">var</span> list = element.children;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; list.length; i++) {
        traverse(list[i], callback);
    }
}
</code></pre>
<h5 id="33&#x3001;&#x539F;&#x751F;js&#x5C01;&#x88C5;ajax&#xFF08;1&#xFF09;"><a name="33&#x3001;&#x539F;&#x751F;js&#x5C01;&#x88C5;ajax&#xFF08;1&#xFF09;" class="anchor-navigation-ex-anchor" href="#33&#x3001;&#x539F;&#x751F;js&#x5C01;&#x88C5;ajax&#xFF08;1&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>33&#x3001;&#x539F;&#x751F;js&#x5C01;&#x88C5;ajax&#xFF08;1&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ajax</span>(<span class="hljs-params">method, url, callback, data, flag</span>) </span>{
    <span class="hljs-keyword">var</span> xhr;
    flag = flag || <span class="hljs-literal">true</span>;
    method = method.toUpperCase();
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.XMLHttpRequest) {
        xhr = <span class="hljs-keyword">new</span> XMLHttpRequest();
    } <span class="hljs-keyword">else</span> {
        xhr = <span class="hljs-keyword">new</span> ActiveXObject(<span class="hljs-string">&apos;Microsoft.XMLHttp&apos;</span>);
    }
    xhr.onreadystatechange = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">if</span> (xhr.readyState == <span class="hljs-number">4</span> &amp;&amp; xhr.status == <span class="hljs-number">200</span>) {
            <span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span>)
            callback(xhr.responseText);
        }
    }

    <span class="hljs-keyword">if</span> (method == <span class="hljs-string">&apos;GET&apos;</span>) {
        <span class="hljs-keyword">var</span> date = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(),
        timer = date.getTime();
        xhr.open(<span class="hljs-string">&apos;GET&apos;</span>, url + <span class="hljs-string">&apos;?&apos;</span> + data + <span class="hljs-string">&apos;&amp;timer&apos;</span> + timer, flag);
        xhr.send()
        } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (method == <span class="hljs-string">&apos;POST&apos;</span>) {
        xhr.open(<span class="hljs-string">&apos;POST&apos;</span>, url, flag);
        xhr.setRequestHeader(<span class="hljs-string">&apos;Content-Type&apos;</span>, <span class="hljs-string">&apos;application/x-www-form-urlencoded&apos;</span>);
        xhr.send(data);
    }
}
</code></pre>
<h5 id="34&#x3001;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;script"><a name="34&#x3001;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;script" class="anchor-navigation-ex-anchor" href="#34&#x3001;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;script"><i class="fa fa-link" aria-hidden="true"></i></a><strong>34&#x3001;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;script</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">loadScript</span>(<span class="hljs-params">url, callback</span>) </span>{
    <span class="hljs-keyword">var</span> oscript = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;script&apos;</span>);
    <span class="hljs-keyword">if</span> (oscript.readyState) { <span class="hljs-comment">// ie8&#x53CA;&#x4EE5;&#x4E0B;&#x7248;&#x672C;</span>
        oscript.onreadystatechange = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">if</span> (oscript.readyState === <span class="hljs-string">&apos;complete&apos;</span> || oscript.readyState === <span class="hljs-string">&apos;loaded&apos;</span>) {
                callback();
            }
        }
    } <span class="hljs-keyword">else</span> {
        oscript.onload = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            callback()
        };
    }
    oscript.src = url;
    <span class="hljs-built_in">document</span>.body.appendChild(oscript);
}
</code></pre>
<h5 id="35&#x3001;cookie&#x7BA1;&#x7406;"><a name="35&#x3001;cookie&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#35&#x3001;cookie&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>35&#x3001;cookie&#x7BA1;&#x7406;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> cookie = {
    <span class="hljs-attr">set</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">name, value, time</span>) </span>{
        <span class="hljs-built_in">document</span>.cookie = name + <span class="hljs-string">&apos;=&apos;</span> + value + <span class="hljs-string">&apos;; max-age=&apos;</span> + time;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
    },
    <span class="hljs-attr">remove</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">name</span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.setCookie(name, <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-number">-1</span>);
    },
    <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">name, callback</span>) </span>{
        <span class="hljs-keyword">var</span> allCookieArr = <span class="hljs-built_in">document</span>.cookie.split(<span class="hljs-string">&apos;; &apos;</span>);
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; allCookieArr.length; i++) {
            <span class="hljs-keyword">var</span> itemCookieArr = allCookieArr[i].split(<span class="hljs-string">&apos;=&apos;</span>);
            <span class="hljs-keyword">if</span> (itemCookieArr[<span class="hljs-number">0</span>] === name) {
                <span class="hljs-keyword">return</span> itemCookieArr[<span class="hljs-number">1</span>]
            }
        }
        <span class="hljs-keyword">return</span> <span class="hljs-literal">undefined</span>;
    }
}
</code></pre>
<h5 id="36&#x3001;&#x5B9E;&#x73B0;bind&#x65B9;&#x6CD5;"><a name="36&#x3001;&#x5B9E;&#x73B0;bind&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#36&#x3001;&#x5B9E;&#x73B0;bind&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>36&#x3001;&#x5B9E;&#x73B0;bind()&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myBind = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">target</span>) </span>{
    <span class="hljs-keyword">var</span> target = target || <span class="hljs-built_in">window</span>;
    <span class="hljs-keyword">var</span> _args1 = [].slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>);
    <span class="hljs-keyword">var</span> self = <span class="hljs-keyword">this</span>;
    <span class="hljs-keyword">var</span> temp = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{};
    <span class="hljs-keyword">var</span> F = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">var</span> _args2 = [].slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">0</span>);
        <span class="hljs-keyword">var</span> parasArr = _args1.concat(_args2);
        <span class="hljs-keyword">return</span> self.apply(<span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> temp ? <span class="hljs-keyword">this</span> : target, parasArr)
    }
    temp.prototype = self.prototype;
    F.prototype = <span class="hljs-keyword">new</span> temp();
    <span class="hljs-keyword">return</span> F;
}
</code></pre>
<h5 id="37&#x3001;&#x5B9E;&#x73B0;call&#x65B9;&#x6CD5;"><a name="37&#x3001;&#x5B9E;&#x73B0;call&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#37&#x3001;&#x5B9E;&#x73B0;call&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>37&#x3001;&#x5B9E;&#x73B0;call()&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myCall = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> ctx = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">0</span>] || <span class="hljs-built_in">window</span>;
    ctx.fn = <span class="hljs-keyword">this</span>;
    <span class="hljs-keyword">var</span> args = [];
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">1</span>; i &lt; <span class="hljs-built_in">arguments</span>.length; i++) {
        args.push(<span class="hljs-built_in">arguments</span>[i])
    }
    <span class="hljs-keyword">var</span> result = ctx.fn(...args);
    <span class="hljs-keyword">delete</span> ctx.fn;
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h5 id="38&#x3001;&#x5B9E;&#x73B0;apply&#x65B9;&#x6CD5;"><a name="38&#x3001;&#x5B9E;&#x73B0;apply&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#38&#x3001;&#x5B9E;&#x73B0;apply&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>38&#x3001;&#x5B9E;&#x73B0;apply()&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">Function</span>.prototype.myApply = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">var</span> ctx = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">0</span>] || <span class="hljs-built_in">window</span>;
    ctx.fn = <span class="hljs-keyword">this</span>;
    <span class="hljs-keyword">if</span> (!<span class="hljs-built_in">arguments</span>[<span class="hljs-number">1</span>]) {
        <span class="hljs-keyword">var</span> result = ctx.fn();
        <span class="hljs-keyword">delete</span> ctx.fn;
        <span class="hljs-keyword">return</span> result;
    }
    <span class="hljs-keyword">var</span> result = ctx.fn(...arguments[<span class="hljs-number">1</span>]);
    <span class="hljs-keyword">delete</span> ctx.fn;
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h5 id="39&#x3001;&#x9632;&#x6296;"><a name="39&#x3001;&#x9632;&#x6296;" class="anchor-navigation-ex-anchor" href="#39&#x3001;&#x9632;&#x6296;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>39&#x3001;&#x9632;&#x6296;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">debounce</span>(<span class="hljs-params">handle, delay</span>) </span>{
    <span class="hljs-keyword">var</span> timer = <span class="hljs-literal">null</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">var</span> _self = <span class="hljs-keyword">this</span>,
            _args = <span class="hljs-built_in">arguments</span>;
        clearTimeout(timer);
        timer = setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            handle.apply(_self, _args)
        }, delay)
    }
}
</code></pre>
<h5 id="40&#x3001;&#x8282;&#x6D41;"><a name="40&#x3001;&#x8282;&#x6D41;" class="anchor-navigation-ex-anchor" href="#40&#x3001;&#x8282;&#x6D41;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>40&#x3001;&#x8282;&#x6D41;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">throttle</span>(<span class="hljs-params">handler, wait</span>) </span>{
    <span class="hljs-keyword">var</span> lastTime = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">e</span>) </span>{
        <span class="hljs-keyword">var</span> nowTime = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().getTime();
        <span class="hljs-keyword">if</span> (nowTime - lastTime &gt; wait) {
            handler.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>);
            lastTime = nowTime;
        }
    }
}
</code></pre>
<h5 id="41&#x3001;requestanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;"><a name="41&#x3001;requestanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#41&#x3001;requestanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>41&#x3001;requestAnimFrame&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">window</span>.requestAnimFrame = (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">window</span>.requestAnimationFrame ||
        <span class="hljs-built_in">window</span>.webkitRequestAnimationFrame ||
        <span class="hljs-built_in">window</span>.mozRequestAnimationFrame ||
        <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">callback</span>) </span>{
            <span class="hljs-built_in">window</span>.setTimeout(callback, <span class="hljs-number">1000</span> / <span class="hljs-number">60</span>);
        };
})();
</code></pre>
<h5 id="42&#x3001;cancelanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;"><a name="42&#x3001;cancelanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#42&#x3001;cancelanimframe&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>42&#x3001;cancelAnimFrame&#x517C;&#x5BB9;&#x6027;&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-built_in">window</span>.cancelAnimFrame = (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">window</span>.cancelAnimationFrame ||
        <span class="hljs-built_in">window</span>.webkitCancelAnimationFrame ||
        <span class="hljs-built_in">window</span>.mozCancelAnimationFrame ||
        <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">id</span>) </span>{
            <span class="hljs-built_in">window</span>.clearTimeout(id);
        };
})();
</code></pre>
<h5 id="43&#x3001;jsonp&#x5E95;&#x5C42;&#x65B9;&#x6CD5;"><a name="43&#x3001;jsonp&#x5E95;&#x5C42;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#43&#x3001;jsonp&#x5E95;&#x5C42;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>43&#x3001;jsonp&#x5E95;&#x5C42;&#x65B9;&#x6CD5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">jsonp</span>(<span class="hljs-params">url, callback</span>) </span>{
    <span class="hljs-keyword">var</span> oscript = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;script&apos;</span>);
    <span class="hljs-keyword">if</span> (oscript.readyState) { <span class="hljs-comment">// ie8&#x53CA;&#x4EE5;&#x4E0B;&#x7248;&#x672C;</span>
        oscript.onreadystatechange = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">if</span> (oscript.readyState === <span class="hljs-string">&apos;complete&apos;</span> || oscript.readyState === <span class="hljs-string">&apos;loaded&apos;</span>) {
                callback();
            }
        }
    } <span class="hljs-keyword">else</span> {
        oscript.onload = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            callback()
        };
    }
    oscript.src = url;
    <span class="hljs-built_in">document</span>.body.appendChild(oscript);
}
</code></pre>
<h5 id="44&#x3001;&#x83B7;&#x53D6;url&#x4E0A;&#x7684;&#x53C2;&#x6570;&#xFF08;2&#xFF09;"><a name="44&#x3001;&#x83B7;&#x53D6;url&#x4E0A;&#x7684;&#x53C2;&#x6570;&#xFF08;2&#xFF09;" class="anchor-navigation-ex-anchor" href="#44&#x3001;&#x83B7;&#x53D6;url&#x4E0A;&#x7684;&#x53C2;&#x6570;&#xFF08;2&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>44&#x3001;&#x83B7;&#x53D6;url&#x4E0A;&#x7684;&#x53C2;&#x6570;&#xFF08;2&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getUrlParam</span>(<span class="hljs-params">sUrl, sKey</span>) </span>{
    <span class="hljs-keyword">var</span> result = {};
    sUrl.replace(<span class="hljs-regexp">/(\w+)=(\w+)(?=[&amp;|#])/g</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">ele, key, val</span>) </span>{
        <span class="hljs-keyword">if</span> (!result[key]) {
            result[key] = val;
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-keyword">var</span> temp = result[key];
            result[key] = [].concat(temp, val);
        }
    })
    <span class="hljs-keyword">if</span> (!sKey) {
        <span class="hljs-keyword">return</span> result;
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">return</span> result[sKey] || <span class="hljs-string">&apos;&apos;</span>;
    }
}
</code></pre>
<h5 id="45&#x3001;&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;"><a name="45&#x3001;&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;" class="anchor-navigation-ex-anchor" href="#45&#x3001;&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>45&#x3001;&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">formatDate</span>(<span class="hljs-params">t, str</span>) </span>{
    <span class="hljs-keyword">var</span> obj = {
        <span class="hljs-attr">yyyy</span>: t.getFullYear(),
        <span class="hljs-attr">yy</span>: (<span class="hljs-string">&quot;&quot;</span> + t.getFullYear()).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">M</span>: t.getMonth() + <span class="hljs-number">1</span>,
        <span class="hljs-attr">MM</span>: (<span class="hljs-string">&quot;0&quot;</span> + (t.getMonth() + <span class="hljs-number">1</span>)).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">d</span>: t.getDate(),
        <span class="hljs-attr">dd</span>: (<span class="hljs-string">&quot;0&quot;</span> + t.getDate()).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">H</span>: t.getHours(),
        <span class="hljs-attr">HH</span>: (<span class="hljs-string">&quot;0&quot;</span> + t.getHours()).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">h</span>: t.getHours() % <span class="hljs-number">12</span>,
        <span class="hljs-attr">hh</span>: (<span class="hljs-string">&quot;0&quot;</span> + t.getHours() % <span class="hljs-number">12</span>).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">m</span>: t.getMinutes(),
        <span class="hljs-attr">mm</span>: (<span class="hljs-string">&quot;0&quot;</span> + t.getMinutes()).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">s</span>: t.getSeconds(),
        <span class="hljs-attr">ss</span>: (<span class="hljs-string">&quot;0&quot;</span> + t.getSeconds()).slice(<span class="hljs-number">-2</span>),
        <span class="hljs-attr">w</span>: [<span class="hljs-string">&apos;&#x65E5;&apos;</span>, <span class="hljs-string">&apos;&#x4E00;&apos;</span>, <span class="hljs-string">&apos;&#x4E8C;&apos;</span>, <span class="hljs-string">&apos;&#x4E09;&apos;</span>, <span class="hljs-string">&apos;&#x56DB;&apos;</span>, <span class="hljs-string">&apos;&#x4E94;&apos;</span>, <span class="hljs-string">&apos;&#x516D;&apos;</span>][t.getDay()]
    };
    <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/([a-z]+)/ig</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">$<span class="hljs-number">1</span></span>) </span>{
        <span class="hljs-keyword">return</span> obj[$<span class="hljs-number">1</span>]
    });
}
</code></pre>
<h5 id="46&#x3001;&#x9A8C;&#x8BC1;&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;"><a name="46&#x3001;&#x9A8C;&#x8BC1;&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#46&#x3001;&#x9A8C;&#x8BC1;&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>46&#x3001;&#x9A8C;&#x8BC1;&#x90AE;&#x7BB1;&#x7684;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isAvailableEmail</span>(<span class="hljs-params">sEmail</span>) </span>{
    <span class="hljs-keyword">var</span> reg = <span class="hljs-regexp">/^([\w+.])+@\w+([.]\w+)+$/</span>
    <span class="hljs-keyword">return</span> reg.test(sEmail)
}
</code></pre>
<h5 id="47&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;"><a name="47&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;" class="anchor-navigation-ex-anchor" href="#47&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>47&#x3001;&#x51FD;&#x6570;&#x67EF;&#x91CC;&#x5316;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-comment">//&#x662F;&#x628A;&#x63A5;&#x53D7;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;&#x53D8;&#x6362;&#x6210;&#x63A5;&#x53D7;&#x4E00;&#x4E2A;&#x5355;&#x4E00;&#x53C2;&#x6570;(&#x6700;&#x521D;&#x51FD;&#x6570;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;)&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x63A5;&#x53D7;&#x4F59;&#x4E0B;&#x7684;&#x53C2;&#x6570;&#x4E14;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x7684;&#x65B0;&#x51FD;&#x6570;&#x7684;&#x6280;&#x672F;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">curryIt</span>(<span class="hljs-params">fn</span>) </span>{
    <span class="hljs-keyword">var</span> length = fn.length,
        args = [];
    <span class="hljs-keyword">var</span> result = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">arg</span>) </span>{
        args.push(arg);
        length--;
        <span class="hljs-keyword">if</span> (length &lt;= <span class="hljs-number">0</span>) {
            <span class="hljs-keyword">return</span> fn.apply(<span class="hljs-keyword">this</span>, args);
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-keyword">return</span> result;
        }
    }
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h5 id="48&#x3001;&#x5927;&#x6570;&#x76F8;&#x52A0;"><a name="48&#x3001;&#x5927;&#x6570;&#x76F8;&#x52A0;" class="anchor-navigation-ex-anchor" href="#48&#x3001;&#x5927;&#x6570;&#x76F8;&#x52A0;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>48&#x3001;&#x5927;&#x6570;&#x76F8;&#x52A0;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sumBigNumber</span>(<span class="hljs-params">a, b</span>) </span>{
    <span class="hljs-keyword">var</span> res = <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-comment">//&#x7ED3;&#x679C;</span>
        temp = <span class="hljs-number">0</span>; <span class="hljs-comment">//&#x6309;&#x4F4D;&#x52A0;&#x7684;&#x7ED3;&#x679C;&#x53CA;&#x8FDB;&#x4F4D;</span>
    a = a.split(<span class="hljs-string">&apos;&apos;</span>);
    b = b.split(<span class="hljs-string">&apos;&apos;</span>);
    <span class="hljs-keyword">while</span> (a.length || b.length || temp) {
        <span class="hljs-comment">//~~&#x6309;&#x4F4D;&#x975E; 1.&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF0C;&#x8F6C;&#x6362;&#x6210;&#x6570;&#x5B57; 2.~~undefined==0 </span>
        temp += ~~a.pop() + ~~b.pop();
        res = (temp % <span class="hljs-number">10</span>) + res;
        temp = temp &gt; <span class="hljs-number">9</span>;
    }
    <span class="hljs-keyword">return</span> res.replace(<span class="hljs-regexp">/^0+/</span>, <span class="hljs-string">&apos;&apos;</span>);
}
</code></pre>
<h5 id="49&#x3001;&#x5355;&#x4F8B;&#x6A21;&#x5F0F;"><a name="49&#x3001;&#x5355;&#x4F8B;&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#49&#x3001;&#x5355;&#x4F8B;&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>49&#x3001;&#x5355;&#x4F8B;&#x6A21;&#x5F0F;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getSingle</span>(<span class="hljs-params">func</span>) </span>{
    <span class="hljs-keyword">var</span> result;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">if</span> (!result) {
            result = <span class="hljs-keyword">new</span> func(<span class="hljs-built_in">arguments</span>);
        }
        <span class="hljs-keyword">return</span> result;
    }
}
</code></pre>
<h5 id="50&#x3001;&#x52A0;&#x8F7D;js--css--style"><a name="50&#x3001;&#x52A0;&#x8F7D;js--css--style" class="anchor-navigation-ex-anchor" href="#50&#x3001;&#x52A0;&#x8F7D;js--css--style"><i class="fa fa-link" aria-hidden="true"></i></a><strong>50&#x3001;&#x52A0;&#x8F7D;js || css || style</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> loadRes = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name, type, fn</span>) </span>{ <span class="hljs-comment">// &#x52A0;&#x8F7D;js || css || style</span>
  <span class="hljs-keyword">let</span> ref
  <span class="hljs-keyword">if</span> (type === <span class="hljs-string">&apos;js&apos;</span>) { <span class="hljs-comment">// &#x5916;&#x90E8;js</span>
    ref = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;script&apos;</span>)
    ref.setAttribute(<span class="hljs-string">&apos;type&apos;</span>, <span class="hljs-string">&apos;text/JavaScript&apos;</span>)
    ref.setAttribute(<span class="hljs-string">&apos;src&apos;</span>, name)
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (type === <span class="hljs-string">&apos;css&apos;</span>) { <span class="hljs-comment">// &#x5916;&#x90E8;css</span>
    ref = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;link&apos;</span>)
    ref.setAttribute(<span class="hljs-string">&apos;rel&apos;</span>, <span class="hljs-string">&apos;stylesheet&apos;</span>)
    ref.setAttribute(<span class="hljs-string">&apos;type&apos;</span>, <span class="hljs-string">&apos;text/css&apos;</span>)
    ref.setAttribute(<span class="hljs-string">&apos;href&apos;</span>, name)
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (type === <span class="hljs-string">&apos;style&apos;</span>) { <span class="hljs-comment">// style</span>
    ref = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;style&apos;</span>)
    ref.innerhtml = name
  }
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> ref !== <span class="hljs-string">&apos;undefined&apos;</span>) {
    <span class="hljs-built_in">document</span>.getElementsByTagName(<span class="hljs-string">&apos;head&apos;</span>)[<span class="hljs-number">0</span>].appendChild(ref)
    ref.onload = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">// &#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x6267;&#x884C;</span>
      <span class="hljs-keyword">typeof</span> fn === <span class="hljs-string">&apos;function&apos;</span> &amp;&amp; fn()
    }
  }
}
</code></pre>
<h5 id="51&#x3001;&#x83B7;&#x53D6;url&#x53C2;&#x6570;&#xFF08;3&#xFF09;"><a name="51&#x3001;&#x83B7;&#x53D6;url&#x53C2;&#x6570;&#xFF08;3&#xFF09;" class="anchor-navigation-ex-anchor" href="#51&#x3001;&#x83B7;&#x53D6;url&#x53C2;&#x6570;&#xFF08;3&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>51&#x3001;&#x83B7;&#x53D6;url&#x53C2;&#x6570;&#xFF08;3&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> getUrlParam = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{ <span class="hljs-comment">// &#x83B7;&#x53D6;url&#x53C2;&#x6570;</span>
  <span class="hljs-keyword">let</span> reg = <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;(^|&amp;?)&apos;</span> + name + <span class="hljs-string">&apos;=([^&amp;]*)(&amp;|$)&apos;</span>, <span class="hljs-string">&apos;i&apos;</span>)
  <span class="hljs-keyword">let</span> r = <span class="hljs-built_in">window</span>.location.href.substr(<span class="hljs-number">1</span>).match(reg)
  <span class="hljs-keyword">if</span> (r != <span class="hljs-literal">null</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">decodeURI</span>(r[<span class="hljs-number">2</span>])
  }
  <span class="hljs-keyword">return</span> <span class="hljs-literal">undefined</span>
}
</code></pre>
<h5 id="52&#x3001;&#x672C;&#x5730;&#x5B58;&#x50A8;"><a name="52&#x3001;&#x672C;&#x5730;&#x5B58;&#x50A8;" class="anchor-navigation-ex-anchor" href="#52&#x3001;&#x672C;&#x5730;&#x5B58;&#x50A8;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>52&#x3001;&#x672C;&#x5730;&#x5B58;&#x50A8;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> store = { <span class="hljs-comment">// &#x672C;&#x5730;&#x5B58;&#x50A8;</span>
  set: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name, value, day</span>) </span>{ <span class="hljs-comment">// &#x8BBE;&#x7F6E;</span>
    <span class="hljs-keyword">let</span> d = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>()
    <span class="hljs-keyword">let</span> time = <span class="hljs-number">0</span>
    day = (<span class="hljs-keyword">typeof</span>(day) === <span class="hljs-string">&apos;undefined&apos;</span> || !day) ? <span class="hljs-number">1</span> : day <span class="hljs-comment">// &#x65F6;&#x95F4;,&#x9ED8;&#x8BA4;&#x5B58;&#x50A8;1&#x5929;</span>
    time = d.setHours(d.getHours() + (<span class="hljs-number">24</span> * day)) <span class="hljs-comment">// &#x6BEB;&#x79D2;</span>
    localStorage.setItem(name, <span class="hljs-built_in">JSON</span>.stringify({
      <span class="hljs-attr">data</span>: value,
      <span class="hljs-attr">time</span>: time
    }))
  },
  <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{ <span class="hljs-comment">// &#x83B7;&#x53D6;</span>
    <span class="hljs-keyword">let</span> data = localStorage.getItem(name)
    <span class="hljs-keyword">if</span> (!data) {
      <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>
    }
    <span class="hljs-keyword">let</span> obj = <span class="hljs-built_in">JSON</span>.parse(data)
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().getTime() &gt; obj.time) { <span class="hljs-comment">// &#x8FC7;&#x671F;</span>
      localStorage.removeItem(name)
      <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> obj.data
    }
  },
  <span class="hljs-attr">clear</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{ <span class="hljs-comment">// &#x6E05;&#x7A7A;</span>
    <span class="hljs-keyword">if</span> (name) { <span class="hljs-comment">// &#x5220;&#x9664;&#x952E;&#x4E3A;name&#x7684;&#x7F13;&#x5B58;</span>
      localStorage.removeItem(name)
    } <span class="hljs-keyword">else</span> { <span class="hljs-comment">// &#x6E05;&#x7A7A;&#x5168;&#x90E8;</span>
      localStorage.clear()
    }
  }
}
</code></pre>
<h5 id="53&#x3001;cookie&#x64CD;&#x4F5C;&#x3010;set&#xFF0C;get&#xFF0C;del&#x3011;"><a name="53&#x3001;cookie&#x64CD;&#x4F5C;&#x3010;set&#xFF0C;get&#xFF0C;del&#x3011;" class="anchor-navigation-ex-anchor" href="#53&#x3001;cookie&#x64CD;&#x4F5C;&#x3010;set&#xFF0C;get&#xFF0C;del&#x3011;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>53&#x3001;cookie&#x64CD;&#x4F5C;&#x3010;set&#xFF0C;get&#xFF0C;del&#x3011;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> cookie = { <span class="hljs-comment">// cookie&#x64CD;&#x4F5C;&#x3010;set&#xFF0C;get&#xFF0C;del&#x3011;</span>
  set: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name, value, day</span>) </span>{
    <span class="hljs-keyword">let</span> oDate = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>()
    oDate.setDate(oDate.getDate() + (day || <span class="hljs-number">30</span>))
    <span class="hljs-built_in">document</span>.cookie = name + <span class="hljs-string">&apos;=&apos;</span> + value + <span class="hljs-string">&apos;;expires=&apos;</span> + oDate + <span class="hljs-string">&quot;; path=/;&quot;</span>
  },
  <span class="hljs-attr">get</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{
    <span class="hljs-keyword">let</span> str = <span class="hljs-built_in">document</span>.cookie
    <span class="hljs-keyword">let</span> arr = str.split(<span class="hljs-string">&apos;; &apos;</span>)
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; arr.length; i++) {
      <span class="hljs-keyword">let</span> newArr = arr[i].split(<span class="hljs-string">&apos;=&apos;</span>)
      <span class="hljs-keyword">if</span> (newArr[<span class="hljs-number">0</span>] === name) {
        <span class="hljs-keyword">return</span> newArr[<span class="hljs-number">1</span>]
      }
    }
  },
  <span class="hljs-attr">del</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">name</span>) </span>{
    <span class="hljs-keyword">this</span>.set(name, <span class="hljs-string">&apos;&apos;</span>, <span class="hljs-number">-1</span>)
  }
}
</code></pre>
<h5 id="54&#x3001;js&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x6837;&#x5F0F;&#x3010;&#x652F;&#x6301;&#x5185;&#x8054;&#x3011;"><a name="54&#x3001;js&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x6837;&#x5F0F;&#x3010;&#x652F;&#x6301;&#x5185;&#x8054;&#x3011;" class="anchor-navigation-ex-anchor" href="#54&#x3001;js&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x6837;&#x5F0F;&#x3010;&#x652F;&#x6301;&#x5185;&#x8054;&#x3011;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>54&#x3001;Js&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x6837;&#x5F0F;&#x3010;&#x652F;&#x6301;&#x5185;&#x8054;&#x3011;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> getRealStyle = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj, styleName</span>) </span>{ <span class="hljs-comment">// Js&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x6837;&#x5F0F;&#x3010;&#x652F;&#x6301;&#x5185;&#x8054;&#x3011;</span>
  <span class="hljs-keyword">var</span> realStyle = <span class="hljs-literal">null</span>
  <span class="hljs-keyword">if</span> (obj.currentStyle) {
    realStyle = obj.currentStyle[styleName]
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-built_in">window</span>.getComputedStyle) {
    realStyle = <span class="hljs-built_in">window</span>.getComputedStyle(obj, <span class="hljs-literal">null</span>)[styleName]
  }
  <span class="hljs-keyword">return</span> realStyle
}
</code></pre>
<h5 id="55&#x3001;&#x65F6;&#x95F4;&#x683C;&#x5F0F;&#x5316;"><a name="55&#x3001;&#x65F6;&#x95F4;&#x683C;&#x5F0F;&#x5316;" class="anchor-navigation-ex-anchor" href="#55&#x3001;&#x65F6;&#x95F4;&#x683C;&#x5F0F;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>55&#x3001;&#x65F6;&#x95F4;&#x683C;&#x5F0F;&#x5316;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> formatDate = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">fmt, date</span>) </span>{ <span class="hljs-comment">// &#x65F6;&#x95F4;&#x683C;&#x5F0F;&#x5316; &#x3010;&apos;yyyy-MM-dd hh:mm:ss&apos;,&#x65F6;&#x95F4;&#x3011;</span>
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> date !== <span class="hljs-string">&apos;object&apos;</span>) {
    date = !date ? <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>() : <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(date)
  }
  <span class="hljs-keyword">var</span> o = {
    <span class="hljs-string">&apos;M+&apos;</span>: date.getMonth() + <span class="hljs-number">1</span>, <span class="hljs-comment">// &#x6708;&#x4EFD;</span>
    <span class="hljs-string">&apos;d+&apos;</span>: date.getDate(), <span class="hljs-comment">// &#x65E5;</span>
    <span class="hljs-string">&apos;h+&apos;</span>: date.getHours(), <span class="hljs-comment">// &#x5C0F;&#x65F6;</span>
    <span class="hljs-string">&apos;m+&apos;</span>: date.getMinutes(), <span class="hljs-comment">// &#x5206;</span>
    <span class="hljs-string">&apos;s+&apos;</span>: date.getSeconds(), <span class="hljs-comment">// &#x79D2;</span>
    <span class="hljs-string">&apos;q+&apos;</span>: <span class="hljs-built_in">Math</span>.floor((date.getMonth() + <span class="hljs-number">3</span>) / <span class="hljs-number">3</span>), <span class="hljs-comment">// &#x5B63;&#x5EA6;</span>
    <span class="hljs-string">&apos;S&apos;</span>: date.getMilliseconds() <span class="hljs-comment">// &#x6BEB;&#x79D2;</span>
  }
  <span class="hljs-keyword">if</span> (<span class="hljs-regexp">/(y+)/</span>.test(fmt)) {
    fmt = fmt.replace(<span class="hljs-built_in">RegExp</span>.$<span class="hljs-number">1</span>, (date.getFullYear() + <span class="hljs-string">&apos;&apos;</span>).substr(<span class="hljs-number">4</span> - <span class="hljs-built_in">RegExp</span>.$<span class="hljs-number">1.</span>length))
  }
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> k <span class="hljs-keyword">in</span> o) {
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;(&apos;</span> + k + <span class="hljs-string">&apos;)&apos;</span>).test(fmt)) {
      fmt = fmt.replace(<span class="hljs-built_in">RegExp</span>.$<span class="hljs-number">1</span>, (<span class="hljs-built_in">RegExp</span>.$<span class="hljs-number">1.</span>length === <span class="hljs-number">1</span>) ? (o[k]) : ((<span class="hljs-string">&apos;00&apos;</span> + o[k]).substr((<span class="hljs-string">&apos;&apos;</span> + o[k]).length)))
    }
  }
  <span class="hljs-keyword">return</span> fmt
}
</code></pre>
<h5 id="56&#x3001;&#x539F;&#x751F;ajax&#x64CD;&#x4F5C;&#xFF08;2&#xFF09;"><a name="56&#x3001;&#x539F;&#x751F;ajax&#x64CD;&#x4F5C;&#xFF08;2&#xFF09;" class="anchor-navigation-ex-anchor" href="#56&#x3001;&#x539F;&#x751F;ajax&#x64CD;&#x4F5C;&#xFF08;2&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>56&#x3001;&#x539F;&#x751F;ajax&#x64CD;&#x4F5C;&#xFF08;2&#xFF09;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> ajax = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">conf</span>) </span>{ <span class="hljs-comment">// ajax&#x64CD;&#x4F5C;</span>
  <span class="hljs-keyword">let</span> url = conf.url,
      data = conf.data,
      senData = [], <span class="hljs-comment">// &#x5C01;&#x88C5;&#x540E;&#x7684;&#x6570;&#x636E;</span>
      <span class="hljs-keyword">async</span> = conf.async !== <span class="hljs-literal">undefined</span> ? conf.async : <span class="hljs-literal">true</span>, <span class="hljs-comment">// ture&#x4E3A;&#x5F02;&#x6B65;&#x8BF7;&#x6C42;</span>
      type = conf.type || <span class="hljs-string">&apos;get&apos;</span>, <span class="hljs-comment">// &#x9ED8;&#x8BA4;&#x8BF7;&#x6C42;&#x65B9;&#x5F0F;get</span>
      dataType = conf.dataType || <span class="hljs-string">&apos;json&apos;</span>,
      contenType = conf.contenType || <span class="hljs-string">&apos;application/x-www-form-urlencoded&apos;</span>,
      success = conf.success,
      error = conf.error,
      isForm = conf.isForm || <span class="hljs-literal">false</span>, <span class="hljs-comment">// &#x662F;&#x5426;formdata</span>
      header = conf.header || {}, <span class="hljs-comment">// &#x5934;&#x90E8;&#x4FE1;&#x606F;</span>
      xhr = <span class="hljs-string">&apos;&apos;</span> <span class="hljs-comment">// &#x521B;&#x5EFA;ajax&#x5F15;&#x64CE;&#x5BF9;&#x8C61;</span>
  <span class="hljs-keyword">if</span> (data == <span class="hljs-literal">null</span>) {
    senData = <span class="hljs-string">&apos;&apos;</span>
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> data === <span class="hljs-string">&apos;object&apos;</span> &amp;&amp; !isForm) { <span class="hljs-comment">// &#x5982;&#x679C;data&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x8F6C;&#x6362;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;</span>
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> k <span class="hljs-keyword">in</span> data) {
      senData.push(<span class="hljs-built_in">encodeURIComponent</span>(k) + <span class="hljs-string">&apos;=&apos;</span> + <span class="hljs-built_in">encodeURIComponent</span>(data[k]))
    }
    senData = senData.join(<span class="hljs-string">&apos;&amp;&apos;</span>)
  } <span class="hljs-keyword">else</span> {
    senData = data
  }
  <span class="hljs-keyword">try</span> {
    xhr = <span class="hljs-keyword">new</span> ActiveXObject(<span class="hljs-string">&apos;microsoft.xmlhttp&apos;</span>) <span class="hljs-comment">// IE&#x5185;&#x6838;&#x7CFB;&#x5217;&#x6D4F;&#x89C8;&#x5668;</span>
  } <span class="hljs-keyword">catch</span> (e1) {
    <span class="hljs-keyword">try</span> {
      xhr = <span class="hljs-keyword">new</span> XMLHttpRequest() <span class="hljs-comment">// &#x975E;IE&#x5185;&#x6838;&#x6D4F;&#x89C8;&#x5668;</span>
    } <span class="hljs-keyword">catch</span> (e2) {
      <span class="hljs-keyword">if</span> (error != <span class="hljs-literal">null</span>) {
        error(<span class="hljs-string">&apos;&#x4E0D;&#x652F;&#x6301;ajax&#x8BF7;&#x6C42;&apos;</span>)
      }
    }
  };
  xhr.open(type, type !== <span class="hljs-string">&apos;get&apos;</span> ? url : url + <span class="hljs-string">&apos;?&apos;</span> + senData, <span class="hljs-keyword">async</span>)
  <span class="hljs-keyword">if</span> (type !== <span class="hljs-string">&apos;get&apos;</span> &amp;&amp; !isForm) {
    xhr.setRequestHeader(<span class="hljs-string">&apos;content-type&apos;</span>, contenType)
  }
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> h <span class="hljs-keyword">in</span> header) {
    xhr.setRequestHeader(h, header[h])
  }
  xhr.send(type !== <span class="hljs-string">&apos;get&apos;</span> ? senData : <span class="hljs-literal">null</span>)
  xhr.onreadystatechange = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (xhr.readyState === <span class="hljs-number">4</span>) {
      <span class="hljs-keyword">if</span> (xhr.status &gt;= <span class="hljs-number">200</span> &amp;&amp; xhr.status &lt; <span class="hljs-number">300</span>) {
        <span class="hljs-keyword">if</span> (dataType === <span class="hljs-string">&apos;json&apos;</span> &amp;&amp; success != <span class="hljs-literal">null</span>) {
          <span class="hljs-keyword">let</span> res = <span class="hljs-string">&apos;&apos;</span>
          <span class="hljs-keyword">try</span> {
            res = <span class="hljs-built_in">eval</span>(<span class="hljs-string">&apos;(&apos;</span> + xhr.responseText + <span class="hljs-string">&apos;)&apos;</span>)
          } <span class="hljs-keyword">catch</span> (e) {
            <span class="hljs-built_in">console</span>.log(e)
          }
          success(res) <span class="hljs-comment">// &#x5C06;json&#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x6362;&#x4E3A;js&#x5BF9;&#x8C61;</span>
        };
      } <span class="hljs-keyword">else</span> {
        <span class="hljs-keyword">if</span> (error != <span class="hljs-literal">null</span>) {
          error(<span class="hljs-string">&apos;&#x901A;&#x8BAF;&#x5931;&#x8D25;!&apos;</span> + xhr.status)
        }
      }
    }
  }
}
</code></pre>
<h5 id="57&#x3001;fetch&#x8BF7;&#x6C42;&#x7684;&#x5C01;&#x88C5;"><a name="57&#x3001;fetch&#x8BF7;&#x6C42;&#x7684;&#x5C01;&#x88C5;" class="anchor-navigation-ex-anchor" href="#57&#x3001;fetch&#x8BF7;&#x6C42;&#x7684;&#x5C01;&#x88C5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>57&#x3001;fetch&#x8BF7;&#x6C42;&#x7684;&#x5C01;&#x88C5;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> fetch = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">url, setting</span>) </span>{ <span class="hljs-comment">// fetch&#x8BF7;&#x6C42;&#x7684;&#x5C01;&#x88C5;</span>
  <span class="hljs-keyword">let</span> opts = { <span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x53C2;&#x6570;&#x7684;&#x521D;&#x59CB;&#x503C;</span>
    method: (setting.method || <span class="hljs-string">&apos;GET&apos;</span>).toUpperCase(), <span class="hljs-comment">// &#x8BF7;&#x6C42;&#x65B9;&#x5F0F;</span>
    headers: setting.headers || {}, <span class="hljs-comment">// &#x8BF7;&#x6C42;&#x5934;&#x8BBE;&#x7F6E;</span>
    credentials: setting.credentials || <span class="hljs-literal">true</span>, <span class="hljs-comment">// &#x8BBE;&#x7F6E;cookie&#x662F;&#x5426;&#x4E00;&#x8D77;&#x53D1;&#x9001;</span>
    body: setting.body || {},
    <span class="hljs-attr">mode</span>: setting.mode || <span class="hljs-string">&apos;no-cors&apos;</span>, <span class="hljs-comment">// &#x53EF;&#x4EE5;&#x8BBE;&#x7F6E; cors, no-cors, same-origin</span>
    redirect: setting.redirect || <span class="hljs-string">&apos;follow&apos;</span>, <span class="hljs-comment">// follow, error, manual</span>
    cache: setting.cache || <span class="hljs-string">&apos;default&apos;</span> <span class="hljs-comment">// &#x8BBE;&#x7F6E; cache &#x6A21;&#x5F0F; (default, reload, no-cache)</span>
  }
  <span class="hljs-keyword">let</span> dataType = setting.dataType || <span class="hljs-string">&apos;json&apos;</span> <span class="hljs-comment">// &#x89E3;&#x6790;&#x65B9;&#x5F0F;</span>
  <span class="hljs-keyword">let</span> data = setting.data || <span class="hljs-string">&apos;&apos;</span> <span class="hljs-comment">// &#x53C2;&#x6570;</span>
  <span class="hljs-keyword">let</span> paramsFormat = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj</span>) </span>{ <span class="hljs-comment">// &#x53C2;&#x6570;&#x683C;&#x5F0F;</span>
    <span class="hljs-keyword">var</span> str = <span class="hljs-string">&apos;&apos;</span>
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i <span class="hljs-keyword">in</span> obj) {
      str += <span class="hljs-string">`<span class="hljs-subst">${i}</span>=<span class="hljs-subst">${obj[i]}</span>&amp;`</span>
    }
    <span class="hljs-keyword">return</span> str.split(<span class="hljs-string">&apos;&apos;</span>).slice(<span class="hljs-number">0</span>, <span class="hljs-number">-1</span>).join(<span class="hljs-string">&apos;&apos;</span>)
  }

  <span class="hljs-keyword">if</span> (opts.method === <span class="hljs-string">&apos;GET&apos;</span>) {
    url = url + (data ? <span class="hljs-string">`?<span class="hljs-subst">${paramsFormat(data)}</span>`</span> : <span class="hljs-string">&apos;&apos;</span>)
  } <span class="hljs-keyword">else</span> {
    setting.body = data || {}
  }
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    fetch(url, opts).then(<span class="hljs-keyword">async</span> res =&gt; {
      <span class="hljs-keyword">let</span> data = dataType === <span class="hljs-string">&apos;text&apos;</span> ? <span class="hljs-keyword">await</span> res.text() : dataType === <span class="hljs-string">&apos;blob&apos;</span> ? <span class="hljs-keyword">await</span> res.blob() : <span class="hljs-keyword">await</span> res.json()
      resolve(data)
    }).catch(<span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> {
      reject(e)
    })
  })
}
</code></pre>
<h5 id="58&#x3001;&#x8BBE;&#x5907;&#x5224;&#x65AD;&#xFF1A;android&#x3001;ios&#x3001;web"><a name="58&#x3001;&#x8BBE;&#x5907;&#x5224;&#x65AD;&#xFF1A;android&#x3001;ios&#x3001;web" class="anchor-navigation-ex-anchor" href="#58&#x3001;&#x8BBE;&#x5907;&#x5224;&#x65AD;&#xFF1A;android&#x3001;ios&#x3001;web"><i class="fa fa-link" aria-hidden="true"></i></a><strong>58&#x3001;&#x8BBE;&#x5907;&#x5224;&#x65AD;&#xFF1A;android&#x3001;ios&#x3001;web</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isDevice = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">// &#x5224;&#x65AD;&#x662F;android&#x8FD8;&#x662F;ios&#x8FD8;&#x662F;web</span>
  <span class="hljs-keyword">var</span> ua = navigator.userAgent.toLowerCase()
  <span class="hljs-keyword">if</span> (ua.match(<span class="hljs-regexp">/iPhone\sOS/i</span>) === <span class="hljs-string">&apos;iphone os&apos;</span> || ua.match(<span class="hljs-regexp">/iPad/i</span>) === <span class="hljs-string">&apos;ipad&apos;</span>) { <span class="hljs-comment">// ios</span>
    <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;iOS&apos;</span>
  }
  <span class="hljs-keyword">if</span> (ua.match(<span class="hljs-regexp">/Android/i</span>) === <span class="hljs-string">&apos;android&apos;</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;Android&apos;</span>
  }
  <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;Web&apos;</span>
}
</code></pre>
<h5 id="59&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x4E3A;&#x5FAE;&#x4FE1;"><a name="59&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x4E3A;&#x5FAE;&#x4FE1;" class="anchor-navigation-ex-anchor" href="#59&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x4E3A;&#x5FAE;&#x4FE1;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>59&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x4E3A;&#x5FAE;&#x4FE1;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isWx = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">// &#x5224;&#x65AD;&#x662F;&#x5426;&#x4E3A;&#x5FAE;&#x4FE1;</span>
  <span class="hljs-keyword">var</span> ua = <span class="hljs-built_in">window</span>.navigator.userAgent.toLowerCase()
  <span class="hljs-keyword">if</span> (ua.match(<span class="hljs-regexp">/MicroMessenger/i</span>) === <span class="hljs-string">&apos;micromessenger&apos;</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>
  }
  <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>
}
</code></pre>
<h5 id="60&#x3001;&#x6587;&#x672C;&#x590D;&#x5236;&#x529F;&#x80FD;"><a name="60&#x3001;&#x6587;&#x672C;&#x590D;&#x5236;&#x529F;&#x80FD;" class="anchor-navigation-ex-anchor" href="#60&#x3001;&#x6587;&#x672C;&#x590D;&#x5236;&#x529F;&#x80FD;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>60&#x3001;&#x6587;&#x672C;&#x590D;&#x5236;&#x529F;&#x80FD;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> copyTxt = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">text, fn</span>) </span>{ <span class="hljs-comment">// &#x590D;&#x5236;&#x529F;&#x80FD;</span>
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-built_in">document</span>.execCommand !== <span class="hljs-string">&apos;function&apos;</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x590D;&#x5236;&#x5931;&#x8D25;&#xFF0C;&#x8BF7;&#x957F;&#x6309;&#x590D;&#x5236;&apos;</span>)
    <span class="hljs-keyword">return</span>
  }
  <span class="hljs-keyword">var</span> dom = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;textarea&apos;</span>)
  dom.value = text
  dom.setAttribute(<span class="hljs-string">&apos;style&apos;</span>, <span class="hljs-string">&apos;display: block;width: 1px;height: 1px;&apos;</span>)
  <span class="hljs-built_in">document</span>.body.appendChild(dom)
  dom.select()
  <span class="hljs-keyword">var</span> result = <span class="hljs-built_in">document</span>.execCommand(<span class="hljs-string">&apos;copy&apos;</span>)
  <span class="hljs-built_in">document</span>.body.removeChild(dom)
  <span class="hljs-keyword">if</span> (result) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x590D;&#x5236;&#x6210;&#x529F;&apos;</span>)
    <span class="hljs-keyword">typeof</span> fn === <span class="hljs-string">&apos;function&apos;</span> &amp;&amp; fn()
    <span class="hljs-keyword">return</span>
  }
  <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> <span class="hljs-built_in">document</span>.createRange !== <span class="hljs-string">&apos;function&apos;</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x590D;&#x5236;&#x5931;&#x8D25;&#xFF0C;&#x8BF7;&#x957F;&#x6309;&#x590D;&#x5236;&apos;</span>)
    <span class="hljs-keyword">return</span>
  }
  <span class="hljs-keyword">var</span> range = <span class="hljs-built_in">document</span>.createRange()
  <span class="hljs-keyword">var</span> div = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;div&apos;</span>)
  div.innerhtml = text
  div.setAttribute(<span class="hljs-string">&apos;style&apos;</span>, <span class="hljs-string">&apos;height: 1px;fontSize: 1px;overflow: hidden;&apos;</span>)
  <span class="hljs-built_in">document</span>.body.appendChild(div)
  range.selectNode(div)
  <span class="hljs-keyword">var</span> selection = <span class="hljs-built_in">window</span>.getSelection()
  <span class="hljs-built_in">console</span>.log(selection)
  <span class="hljs-keyword">if</span> (selection.rangeCount &gt; <span class="hljs-number">0</span>) {
    selection.removeAllRanges()
  }
  selection.addRange(range)
  <span class="hljs-built_in">document</span>.execCommand(<span class="hljs-string">&apos;copy&apos;</span>)
  <span class="hljs-keyword">typeof</span> fn === <span class="hljs-string">&apos;function&apos;</span> &amp;&amp; fn()
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x590D;&#x5236;&#x6210;&#x529F;&apos;</span>)
}
</code></pre>
<h5 id="61&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;"><a name="61&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#61&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>61&#x3001;&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isArray = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">arr</span>) </span>{ <span class="hljs-comment">// &#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;</span>
  <span class="hljs-keyword">return</span> <span class="hljs-built_in">Object</span>.prototype.toString.call(arr) === <span class="hljs-string">&apos;[object Array]&apos;</span>
}
</code></pre>
<h5 id="62&#x3001;&#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x662F;&#x5426;&#x76F8;&#x7B49;"><a name="62&#x3001;&#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x662F;&#x5426;&#x76F8;&#x7B49;" class="anchor-navigation-ex-anchor" href="#62&#x3001;&#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x662F;&#x5426;&#x76F8;&#x7B49;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>62&#x3001;&#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x662F;&#x5426;&#x76F8;&#x7B49;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arrayEqual = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">arr1, arr2</span>) </span>{ <span class="hljs-comment">//&#x5224;&#x65AD;&#x4E24;&#x4E2A;&#x6570;&#x7EC4;&#x662F;&#x5426;&#x76F8;&#x7B49;</span>
  <span class="hljs-keyword">if</span> (arr1 === arr2) <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
  <span class="hljs-keyword">if</span> (arr1.length != arr2.length) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; arr1.length; ++i) {
    <span class="hljs-keyword">if</span> (arr1[i] !== arr2[i]) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
  }
  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
</code></pre>
<h5 id="63&#x3001;&#x65F6;&#x95F4;&#x4E0E;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x6362;"><a name="63&#x3001;&#x65F6;&#x95F4;&#x4E0E;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x6362;" class="anchor-navigation-ex-anchor" href="#63&#x3001;&#x65F6;&#x95F4;&#x4E0E;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>63&#x3001;&#x65F6;&#x95F4;&#x4E0E;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x6362;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> stamp = { <span class="hljs-comment">// &#x65F6;&#x95F4;&#xFF0C;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x6362;</span>
  getTime: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">time</span>) </span>{ <span class="hljs-comment">// &#x65F6;&#x95F4;&#x8F6C;10&#x4F4D;&#x65F6;&#x95F4;&#x6233;</span>
    <span class="hljs-keyword">let</span> date = time ? <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(time) : <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>()
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.round(date.getTime() / <span class="hljs-number">1000</span>)
  },
  <span class="hljs-attr">timeToStr</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">time, fmt</span>) </span>{ <span class="hljs-comment">// 10&#x4F4D;&#x65F6;&#x95F4;&#x6233;&#x8F6C;&#x65F6;&#x95F4;</span>
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>(time * <span class="hljs-number">1000</span>).pattern(fmt || <span class="hljs-string">&apos;yyyy-MM-dd&apos;</span>)
  }
}
</code></pre>
<h5 id="64&#x3001;&#x5E38;&#x7528;&#x6B63;&#x5219;&#x9A8C;&#x8BC1;"><a name="64&#x3001;&#x5E38;&#x7528;&#x6B63;&#x5219;&#x9A8C;&#x8BC1;" class="anchor-navigation-ex-anchor" href="#64&#x3001;&#x5E38;&#x7528;&#x6B63;&#x5219;&#x9A8C;&#x8BC1;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>64&#x3001;&#x5E38;&#x7528;&#x6B63;&#x5219;&#x9A8C;&#x8BC1;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> checkStr = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">str, type</span>) </span>{ <span class="hljs-comment">// &#x5E38;&#x7528;&#x6B63;&#x5219;&#x9A8C;&#x8BC1;&#xFF0C;&#x6CE8;&#x610F;type&#x5927;&#x5C0F;&#x5199;</span>
  <span class="hljs-keyword">switch</span> (type) {
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;phone&apos;</span>: <span class="hljs-comment">// &#x624B;&#x673A;&#x53F7;&#x7801;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^1[3|4|5|6|7|8|9][0-9]{9}$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;tel&apos;</span>: <span class="hljs-comment">// &#x5EA7;&#x673A;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;card&apos;</span>: <span class="hljs-comment">// &#x8EAB;&#x4EFD;&#x8BC1;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;pwd&apos;</span>: <span class="hljs-comment">// &#x5BC6;&#x7801;&#x4EE5;&#x5B57;&#x6BCD;&#x5F00;&#x5934;&#xFF0C;&#x957F;&#x5EA6;&#x5728;6~18&#x4E4B;&#x95F4;&#xFF0C;&#x53EA;&#x80FD;&#x5305;&#x542B;&#x5B57;&#x6BCD;&#x3001;&#x6570;&#x5B57;&#x548C;&#x4E0B;&#x5212;&#x7EBF;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[a-zA-Z]\w{5,17}$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;postal&apos;</span>: <span class="hljs-comment">// &#x90AE;&#x653F;&#x7F16;&#x7801;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/[1-9]\d{5}(?!\d)/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;QQ&apos;</span>: <span class="hljs-comment">// QQ&#x53F7;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[1-9][0-9]{4,9}$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;email&apos;</span>: <span class="hljs-comment">// &#x90AE;&#x7BB1;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[\w-]+(.[\w-]+)*@[\w-]+(.[\w-]+)+$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;money&apos;</span>: <span class="hljs-comment">// &#x91D1;&#x989D;(&#x5C0F;&#x6570;&#x70B9;2&#x4F4D;)</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^\d*(?:.\d{0,2})?$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;URL&apos;</span>: <span class="hljs-comment">// &#x7F51;&#x5740;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/(http|ftp|https):/</span><span class="hljs-regexp">/[\w-_]+(.[\w-_]+)+([\w-.,@?^=%&amp;:/~+#]*[\w-@?^=%&amp;/~+#])?/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;IP&apos;</span>: <span class="hljs-comment">// IP</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;date&apos;</span>: <span class="hljs-comment">// &#x65E5;&#x671F;&#x65F6;&#x95F4;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^(\d{4})-(\d{2})-(\d{2}) (\d{2})(?::\d{2}|:(\d{2}):(\d{2}))$/</span>.test(str) ||
        <span class="hljs-regexp">/^(\d{4})-(\d{2})-(\d{2})$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;number&apos;</span>: <span class="hljs-comment">// &#x6570;&#x5B57;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[0-9]$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;english&apos;</span>: <span class="hljs-comment">// &#x82F1;&#x6587;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[a-zA-Z]+$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;chinese&apos;</span>: <span class="hljs-comment">// &#x4E2D;&#x6587;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[\u4E00-\u9FA5]+$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;lower&apos;</span>: <span class="hljs-comment">// &#x5C0F;&#x5199;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[a-z]+$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;upper&apos;</span>: <span class="hljs-comment">// &#x5927;&#x5199;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/^[A-Z]+$/</span>.test(str)
    <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;HTML&apos;</span>: <span class="hljs-comment">// HTML&#x6807;&#x8BB0;</span>
      <span class="hljs-keyword">return</span> <span class="hljs-regexp">/&lt;(&quot;[^&quot;]*&quot;|&apos;[^&apos;]*&apos;|[^&apos;&quot;&gt;])*&gt;/</span>.test(str)
    <span class="hljs-keyword">default</span>:
      <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>
  }
}
</code></pre>
<h5 id="65&#x3001;&#x662F;&#x5426;&#x4E3A;pc&#x7AEF;"><a name="65&#x3001;&#x662F;&#x5426;&#x4E3A;pc&#x7AEF;" class="anchor-navigation-ex-anchor" href="#65&#x3001;&#x662F;&#x5426;&#x4E3A;pc&#x7AEF;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>65&#x3001;&#x662F;&#x5426;&#x4E3A;PC&#x7AEF;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isPC = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">// &#x662F;&#x5426;&#x4E3A;PC&#x7AEF;</span>
  <span class="hljs-keyword">let</span> userAgentInfo = navigator.userAgent
  <span class="hljs-keyword">let</span> Agents = [<span class="hljs-string">&apos;Android&apos;</span>, <span class="hljs-string">&apos;iPhone&apos;</span>, <span class="hljs-string">&apos;SymbianOS&apos;</span>, <span class="hljs-string">&apos;Windows Phone&apos;</span>, <span class="hljs-string">&apos;iPad&apos;</span>, <span class="hljs-string">&apos;iPod&apos;</span>]
  <span class="hljs-keyword">let</span> flag = <span class="hljs-literal">true</span>
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> v = <span class="hljs-number">0</span>; v &lt; Agents.length; v++) {
    <span class="hljs-keyword">if</span> (userAgentInfo.indexOf(Agents[v]) &gt; <span class="hljs-number">0</span>) {
      flag = <span class="hljs-literal">false</span>
      <span class="hljs-keyword">break</span>
    }
  }
  <span class="hljs-keyword">return</span> flag
}
</code></pre>
<h5 id="66&#x3001;&#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x7A7A;&#x683C;"><a name="66&#x3001;&#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x7A7A;&#x683C;" class="anchor-navigation-ex-anchor" href="#66&#x3001;&#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x7A7A;&#x683C;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>66&#x3001;&#x53BB;&#x9664;&#x5B57;&#x7B26;&#x4E32;&#x7A7A;&#x683C;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> trim = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">str, type</span>) </span>{ <span class="hljs-comment">// &#x53BB;&#x9664;&#x7A7A;&#x683C;&#xFF0C; type:  1-&#x6240;&#x6709;&#x7A7A;&#x683C;  2-&#x524D;&#x540E;&#x7A7A;&#x683C;  3-&#x524D;&#x7A7A;&#x683C; 4-&#x540E;&#x7A7A;&#x683C;</span>
  type = type || <span class="hljs-number">1</span>
  <span class="hljs-keyword">switch</span> (type) {
    <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/\s+/g</span>, <span class="hljs-string">&apos;&apos;</span>)
    <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/(^\s*)|(\s*$)/g</span>, <span class="hljs-string">&apos;&apos;</span>)
    <span class="hljs-keyword">case</span> <span class="hljs-number">3</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/(^\s*)/g</span>, <span class="hljs-string">&apos;&apos;</span>)
    <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/(\s*$)/g</span>, <span class="hljs-string">&apos;&apos;</span>)
    <span class="hljs-keyword">default</span>:
      <span class="hljs-keyword">return</span> str
  }
}
</code></pre>
<h5 id="67&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;"><a name="67&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;" class="anchor-navigation-ex-anchor" href="#67&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>67&#x3001;&#x5B57;&#x7B26;&#x4E32;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> changeCase = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">str, type</span>) </span>{ <span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362; type:  1:&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;  2&#xFF1A;&#x9996;&#x9875;&#x6BCD;&#x5C0F;&#x5199;  3&#xFF1A;&#x5927;&#x5C0F;&#x5199;&#x8F6C;&#x6362;  4&#xFF1A;&#x5168;&#x90E8;&#x5927;&#x5199;  5&#xFF1A;&#x5168;&#x90E8;&#x5C0F;&#x5199;</span>
  type = type || <span class="hljs-number">4</span>
  <span class="hljs-keyword">switch</span> (type) {
    <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/\b\w+\b/g</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">word</span>) </span>{
        <span class="hljs-keyword">return</span> word.substring(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>).toUpperCase() + word.substring(<span class="hljs-number">1</span>).toLowerCase()
      })
    <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
      <span class="hljs-keyword">return</span> str.replace(<span class="hljs-regexp">/\b\w+\b/g</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">word</span>) </span>{
        <span class="hljs-keyword">return</span> word.substring(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>).toLowerCase() + word.substring(<span class="hljs-number">1</span>).toUpperCase()
      })
    <span class="hljs-keyword">case</span> <span class="hljs-number">3</span>:
      <span class="hljs-keyword">return</span> str.split(<span class="hljs-string">&apos;&apos;</span>).map(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">word</span>) </span>{
        <span class="hljs-keyword">if</span> (<span class="hljs-regexp">/[a-z]/</span>.test(word)) {
          <span class="hljs-keyword">return</span> word.toUpperCase()
        } <span class="hljs-keyword">else</span> {
          <span class="hljs-keyword">return</span> word.toLowerCase()
        }
      }).join(<span class="hljs-string">&apos;&apos;</span>)
    <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:
      <span class="hljs-keyword">return</span> str.toUpperCase()
    <span class="hljs-keyword">case</span> <span class="hljs-number">5</span>:
      <span class="hljs-keyword">return</span> str.toLowerCase()
    <span class="hljs-keyword">default</span>:
      <span class="hljs-keyword">return</span> str
  }
}
</code></pre>
<h5 id="68&#x3001;&#x8FC7;&#x6EE4;html&#x4EE3;&#x7801;"><a name="68&#x3001;&#x8FC7;&#x6EE4;html&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#68&#x3001;&#x8FC7;&#x6EE4;html&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>68&#x3001;&#x8FC7;&#x6EE4;html&#x4EE3;&#x7801;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> filterTag = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">str</span>) </span>{ <span class="hljs-comment">// &#x8FC7;&#x6EE4;html&#x4EE3;&#x7801;(&#x628A;&lt;&gt;&#x8F6C;&#x6362;)</span>
  str = str.replace(<span class="hljs-regexp">/&amp;/ig</span>, <span class="hljs-string">&apos;&amp;&apos;</span>)
  str = str.replace(<span class="hljs-regexp">/&lt;/ig</span>, <span class="hljs-string">&apos;&lt;&apos;</span>)
  str = str.replace(<span class="hljs-regexp">/&gt;/ig</span>, <span class="hljs-string">&apos;&gt;&apos;</span>)
  str = str.replace(<span class="hljs-string">&apos; &apos;</span>, <span class="hljs-string">&apos; &apos;</span>)
  <span class="hljs-keyword">return</span> str
}
</code></pre>
<h5 id="69&#x3001;&#x751F;&#x6210;&#x968F;&#x673A;&#x6570;&#x8303;&#x56F4;"><a name="69&#x3001;&#x751F;&#x6210;&#x968F;&#x673A;&#x6570;&#x8303;&#x56F4;" class="anchor-navigation-ex-anchor" href="#69&#x3001;&#x751F;&#x6210;&#x968F;&#x673A;&#x6570;&#x8303;&#x56F4;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>69&#x3001;&#x751F;&#x6210;&#x968F;&#x673A;&#x6570;&#x8303;&#x56F4;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> random = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">min, max</span>) </span>{ <span class="hljs-comment">// &#x751F;&#x6210;&#x968F;&#x673A;&#x6570;&#x8303;&#x56F4;</span>
  <span class="hljs-keyword">if</span> (<span class="hljs-built_in">arguments</span>.length === <span class="hljs-number">2</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.floor(min + <span class="hljs-built_in">Math</span>.random() * ((max + <span class="hljs-number">1</span>) - min))
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>
  }
}
</code></pre>
<h5 id="70&#x3001;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;&#x8F6C;&#x4E2D;&#x6587;&#x5927;&#x5199;&#x6570;&#x5B57;"><a name="70&#x3001;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;&#x8F6C;&#x4E2D;&#x6587;&#x5927;&#x5199;&#x6570;&#x5B57;" class="anchor-navigation-ex-anchor" href="#70&#x3001;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;&#x8F6C;&#x4E2D;&#x6587;&#x5927;&#x5199;&#x6570;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>70&#x3001;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;&#x8F6C;&#x4E2D;&#x6587;&#x5927;&#x5199;&#x6570;&#x5B57;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numberToChinese = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">num</span>) </span>{ <span class="hljs-comment">// &#x5C06;&#x963F;&#x62C9;&#x4F2F;&#x6570;&#x5B57;&#x7FFB;&#x8BD1;&#x6210;&#x4E2D;&#x6587;&#x7684;&#x5927;&#x5199;&#x6570;&#x5B57;</span>
  <span class="hljs-keyword">let</span> AA = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-string">&apos;&#x96F6;&apos;</span>, <span class="hljs-string">&apos;&#x4E00;&apos;</span>, <span class="hljs-string">&apos;&#x4E8C;&apos;</span>, <span class="hljs-string">&apos;&#x4E09;&apos;</span>, <span class="hljs-string">&apos;&#x56DB;&apos;</span>, <span class="hljs-string">&apos;&#x4E94;&apos;</span>, <span class="hljs-string">&apos;&#x516D;&apos;</span>, <span class="hljs-string">&apos;&#x4E03;&apos;</span>, <span class="hljs-string">&apos;&#x516B;&apos;</span>, <span class="hljs-string">&apos;&#x4E5D;&apos;</span>, <span class="hljs-string">&apos;&#x5341;&apos;</span>)
  <span class="hljs-keyword">let</span> BB = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(<span class="hljs-string">&apos;&apos;</span>, <span class="hljs-string">&apos;&#x5341;&apos;</span>, <span class="hljs-string">&apos;&#x767E;&apos;</span>, <span class="hljs-string">&apos;&#x4EDF;&apos;</span>, <span class="hljs-string">&apos;&#x842C;&apos;</span>, <span class="hljs-string">&apos;&#x5104;&apos;</span>, <span class="hljs-string">&apos;&#x70B9;&apos;</span>, <span class="hljs-string">&apos;&apos;</span>)
  <span class="hljs-keyword">let</span> a = (<span class="hljs-string">&apos;&apos;</span> + num).replace(<span class="hljs-regexp">/(^0*)/g</span>, <span class="hljs-string">&apos;&apos;</span>).split(<span class="hljs-string">&apos;.&apos;</span>)
  <span class="hljs-keyword">let</span> k = <span class="hljs-number">0</span>
  <span class="hljs-keyword">let</span> re = <span class="hljs-string">&apos;&apos;</span>
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = a[<span class="hljs-number">0</span>].length - <span class="hljs-number">1</span>; i &gt;= <span class="hljs-number">0</span>; i--) {
    <span class="hljs-keyword">switch</span> (k) {
      <span class="hljs-keyword">case</span> <span class="hljs-number">0</span>:
        re = BB[<span class="hljs-number">7</span>] + re
        <span class="hljs-keyword">break</span>
      <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:
        <span class="hljs-keyword">if</span> (!<span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;0{4}//d{&apos;</span> + (a[<span class="hljs-number">0</span>].length - i - <span class="hljs-number">1</span>) + <span class="hljs-string">&apos;}$&apos;</span>).test(a[<span class="hljs-number">0</span>])) {
          re = BB[<span class="hljs-number">4</span>] + re
        }
        <span class="hljs-keyword">break</span>
      <span class="hljs-keyword">case</span> <span class="hljs-number">8</span>:
        re = BB[<span class="hljs-number">5</span>] + re
        BB[<span class="hljs-number">7</span>] = BB[<span class="hljs-number">5</span>]
        k = <span class="hljs-number">0</span>
        <span class="hljs-keyword">break</span>
    }
    <span class="hljs-keyword">if</span> (k % <span class="hljs-number">4</span> === <span class="hljs-number">2</span> &amp;&amp; a[<span class="hljs-number">0</span>].charAt(i + <span class="hljs-number">2</span>) !== <span class="hljs-number">0</span> &amp;&amp; a[<span class="hljs-number">0</span>].charAt(i + <span class="hljs-number">1</span>) === <span class="hljs-number">0</span>) {
      re = AA[<span class="hljs-number">0</span>] + re
    }
    <span class="hljs-keyword">if</span> (a[<span class="hljs-number">0</span>].charAt(i) !== <span class="hljs-number">0</span>) {
      re = AA[a[<span class="hljs-number">0</span>].charAt(i)] + BB[k % <span class="hljs-number">4</span>] + re
    }
    k++
  }
  <span class="hljs-keyword">if</span> (a.length &gt; <span class="hljs-number">1</span>) { <span class="hljs-comment">// &#x52A0;&#x4E0A;&#x5C0F;&#x6570;&#x90E8;&#x5206;(&#x5982;&#x679C;&#x6709;&#x5C0F;&#x6570;&#x90E8;&#x5206;)</span>
    re += BB[<span class="hljs-number">6</span>]
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; a[<span class="hljs-number">1</span>].length; i++) {
      re += AA[a[<span class="hljs-number">1</span>].charAt(i)]
    }
  }
  <span class="hljs-keyword">if</span> (re === <span class="hljs-string">&apos;&#x4E00;&#x5341;&apos;</span>) {
    re = <span class="hljs-string">&apos;&#x5341;&apos;</span>
  }
  <span class="hljs-keyword">if</span> (re.match(<span class="hljs-regexp">/^&#x4E00;/</span>) &amp;&amp; re.length === <span class="hljs-number">3</span>) {
    re = re.replace(<span class="hljs-string">&apos;&#x4E00;&apos;</span>, <span class="hljs-string">&apos;&apos;</span>)
  }
  <span class="hljs-keyword">return</span> re
}
</code></pre>
<h5 id="71&#x3001;&#x539F;&#x751F;dom&#x64CD;&#x4F5C;"><a name="71&#x3001;&#x539F;&#x751F;dom&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#71&#x3001;&#x539F;&#x751F;dom&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>71&#x3001;&#x539F;&#x751F;dom&#x64CD;&#x4F5C;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> dom = {
  <span class="hljs-attr">$</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">selector</span>) </span>{
    <span class="hljs-keyword">let</span> type = selector.substring(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>)
    <span class="hljs-keyword">if</span> (type === <span class="hljs-string">&apos;#&apos;</span>) {
      <span class="hljs-keyword">if</span> (<span class="hljs-built_in">document</span>.querySelecotor) <span class="hljs-keyword">return</span> <span class="hljs-built_in">document</span>.querySelector(selector)
      <span class="hljs-keyword">return</span> <span class="hljs-built_in">document</span>.getElementById(selector.substring(<span class="hljs-number">1</span>))
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (type === <span class="hljs-string">&apos;.&apos;</span>) {
      <span class="hljs-keyword">if</span> (<span class="hljs-built_in">document</span>.querySelecotorAll) <span class="hljs-keyword">return</span> <span class="hljs-built_in">document</span>.querySelectorAll(selector)
      <span class="hljs-keyword">return</span> <span class="hljs-built_in">document</span>.getElementsByClassName(selector.substring(<span class="hljs-number">1</span>))
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> <span class="hljs-built_in">document</span>[<span class="hljs-string">&apos;querySelectorAll&apos;</span> ? <span class="hljs-string">&apos;querySelectorAll&apos;</span> : <span class="hljs-string">&apos;getElementsByTagName&apos;</span>](selector)
    }
  },
  <span class="hljs-attr">hasClass</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ele, name</span>) </span>{ <span class="hljs-comment">/* &#x68C0;&#x6D4B;&#x7C7B;&#x540D; */</span>
    <span class="hljs-keyword">return</span> ele.className.match(<span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;(\s|^)&apos;</span> + name + <span class="hljs-string">&apos;(\s|$)&apos;</span>))
  },
  <span class="hljs-attr">addClass</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ele, name</span>) </span>{ <span class="hljs-comment">/* &#x6DFB;&#x52A0;&#x7C7B;&#x540D; */</span>
    <span class="hljs-keyword">if</span> (!<span class="hljs-keyword">this</span>.hasClass(ele, name)) ele.className += <span class="hljs-string">&apos; &apos;</span> + name
  },
  <span class="hljs-attr">removeClass</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ele, name</span>) </span>{ <span class="hljs-comment">/* &#x5220;&#x9664;&#x7C7B;&#x540D; */</span>
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.hasClass(ele, name)) {
      <span class="hljs-keyword">let</span> reg = <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">&apos;(\s|^)&apos;</span> + name + <span class="hljs-string">&apos;(\s|$)&apos;</span>)
      ele.className = ele.className.replace(reg, <span class="hljs-string">&apos;&apos;</span>)
    }
  },
  <span class="hljs-attr">replaceClass</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ele, newName, oldName</span>) </span>{ <span class="hljs-comment">/* &#x66FF;&#x6362;&#x7C7B;&#x540D; */</span>
    <span class="hljs-keyword">this</span>.removeClass(ele, oldName)
    <span class="hljs-keyword">this</span>.addClass(ele, newName)
  },
  <span class="hljs-attr">siblings</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">ele</span>) </span>{ <span class="hljs-comment">/* &#x83B7;&#x53D6;&#x5144;&#x5F1F;&#x8282;&#x70B9; */</span>
    <span class="hljs-built_in">console</span>.log(ele.parentNode)
    <span class="hljs-keyword">let</span> chid = ele.parentNode.children,
      eleMatch = []
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>, len = chid.length; i &lt; len; i++) {
      <span class="hljs-keyword">if</span> (chid[i] !== ele) {
        eleMatch.push(chid[i])
      }
    }
    <span class="hljs-keyword">return</span> eleMatch
  },
  <span class="hljs-attr">getByStyle</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj, name</span>) </span>{ <span class="hljs-comment">/* &#x83B7;&#x53D6;&#x884C;&#x95F4;&#x6837;&#x5F0F;&#x5C5E;&#x6027; */</span>
    <span class="hljs-keyword">if</span> (obj.currentStyle) {
      <span class="hljs-keyword">return</span> obj.currentStyle[name]
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> getComputedStyle(obj, <span class="hljs-literal">false</span>)[name]
    }
  },
  <span class="hljs-attr">domToStirng</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">htmlDOM</span>) </span>{ <span class="hljs-comment">/* DOM&#x8F6C;&#x5B57;&#x7B26;&#x4E32; */</span>
    <span class="hljs-keyword">var</span> div = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;div&apos;</span>)
    div.appendChild(htmlDOM)
    <span class="hljs-keyword">return</span> div.innerHTML
  },
  <span class="hljs-attr">stringToDom</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">htmlString</span>) </span>{ <span class="hljs-comment">/* &#x5B57;&#x7B26;&#x4E32;&#x8F6C;DOM */</span>
    <span class="hljs-keyword">var</span> div = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;div&apos;</span>)
    div.innerHTML = htmlString
    <span class="hljs-keyword">return</span> div.children[<span class="hljs-number">0</span>]
  }
}
</code></pre>
<h5 id="72&#x3001;&#x5224;&#x65AD;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;"><a name="72&#x3001;&#x5224;&#x65AD;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;" class="anchor-navigation-ex-anchor" href="#72&#x3001;&#x5224;&#x65AD;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>72&#x3001;&#x5224;&#x65AD;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> imgLoadAll = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">arr, callback</span>) </span>{ <span class="hljs-comment">// &#x56FE;&#x7247;&#x52A0;&#x8F7D;</span>
  <span class="hljs-keyword">let</span> arrImg = []
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; arr.length; i++) {
    <span class="hljs-keyword">let</span> img = <span class="hljs-keyword">new</span> Image()
    img.src = arr[i]
    img.onload = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
      arrImg.push(<span class="hljs-keyword">this</span>)
      <span class="hljs-keyword">if</span> (arrImg.length == arr.length) {
        callback &amp;&amp; callback()
      }
    }
  }
}
</code></pre>
<h5 id="73&#x3001;&#x97F3;&#x9891;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x64CD;&#x4F5C;"><a name="73&#x3001;&#x97F3;&#x9891;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#73&#x3001;&#x97F3;&#x9891;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>73&#x3001;&#x97F3;&#x9891;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x64CD;&#x4F5C;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> loadAudio = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">src, callback</span>) </span>{ <span class="hljs-comment">// &#x97F3;&#x9891;&#x52A0;&#x8F7D;</span>
  <span class="hljs-keyword">var</span> audio = <span class="hljs-keyword">new</span> Audio(src)
  audio.onloadedmetadata = callback
  audio.src = src
}
</code></pre>
<h5 id="74&#x3001;&#x5149;&#x6807;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5B57;&#x7B26;"><a name="74&#x3001;&#x5149;&#x6807;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5B57;&#x7B26;" class="anchor-navigation-ex-anchor" href="#74&#x3001;&#x5149;&#x6807;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5B57;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>74&#x3001;&#x5149;&#x6807;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5B57;&#x7B26;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> insertAtCursor = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">dom, val</span>) </span>{ <span class="hljs-comment">// &#x5149;&#x6807;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5B57;&#x7B26;</span>
  <span class="hljs-keyword">if</span> (<span class="hljs-built_in">document</span>.selection) {
    dom.focus()
    <span class="hljs-keyword">let</span> sel = <span class="hljs-built_in">document</span>.selection.createRange()
    sel.text = val
    sel.select()
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (dom.selectionStart || dom.selectionStart == <span class="hljs-string">&apos;0&apos;</span>) {
    <span class="hljs-keyword">let</span> startPos = dom.selectionStart
    <span class="hljs-keyword">let</span> endPos = dom.selectionEnd
    <span class="hljs-keyword">let</span> restoreTop = dom.scrollTop
    dom.value = dom.value.substring(<span class="hljs-number">0</span>, startPos) + val + dom.value.substring(endPos, dom.value.length)
    <span class="hljs-keyword">if</span> (restoreTop &gt; <span class="hljs-number">0</span>) {
      dom.scrollTop = restoreTop
    }
    dom.focus()
    dom.selectionStart = startPos + val.length
    dom.selectionEnd = startPos + val.length
  } <span class="hljs-keyword">else</span> {
    dom.value += val
    dom.focus()
  }
}
</code></pre>
<h5 id="75&#x3001;&#x56FE;&#x7247;&#x5730;&#x5740;&#x8F6C;base64"><a name="75&#x3001;&#x56FE;&#x7247;&#x5730;&#x5740;&#x8F6C;base64" class="anchor-navigation-ex-anchor" href="#75&#x3001;&#x56FE;&#x7247;&#x5730;&#x5740;&#x8F6C;base64"><i class="fa fa-link" aria-hidden="true"></i></a><strong>75&#x3001;&#x56FE;&#x7247;&#x5730;&#x5740;&#x8F6C;base64</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> getBase64 = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">img</span>) </span>{ <span class="hljs-comment">//&#x4F20;&#x5165;&#x56FE;&#x7247;&#x8DEF;&#x5F84;&#xFF0C;&#x8FD4;&#x56DE;base64&#xFF0C;&#x4F7F;&#x7528;getBase64(url).then(function(base64){},function(err){}); </span>
  <span class="hljs-keyword">let</span> getBase64Image = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">img, width, height</span>) </span>{ <span class="hljs-comment">//width&#x3001;height&#x8C03;&#x7528;&#x65F6;&#x4F20;&#x5165;&#x5177;&#x4F53;&#x50CF;&#x7D20;&#x503C;&#xFF0C;&#x63A7;&#x5236;&#x5927;&#x5C0F;,&#x4E0D;&#x4F20;&#x5219;&#x9ED8;&#x8BA4;&#x56FE;&#x50CF;&#x5927;&#x5C0F;</span>
    <span class="hljs-keyword">let</span> canvas = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&quot;canvas&quot;</span>);
    canvas.width = width ? width : img.width;
    canvas.height = height ? height : img.height;
    <span class="hljs-keyword">let</span> ctx = canvas.getContext(<span class="hljs-string">&quot;2d&quot;</span>);
    ctx.drawImage(img, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.width, canvas.height);
    <span class="hljs-keyword">let</span> dataURL = canvas.toDataURL();
    <span class="hljs-keyword">return</span> dataURL;
  }
  <span class="hljs-keyword">let</span> image = <span class="hljs-keyword">new</span> Image();
  image.crossOrigin = <span class="hljs-string">&apos;&apos;</span>;
  image.src = img;
  <span class="hljs-keyword">let</span> deferred = $.Deferred();
  <span class="hljs-keyword">if</span> (img) {
    image.onload = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
      deferred.resolve(getBase64Image(image));
    }
    <span class="hljs-keyword">return</span> deferred.promise();
  }
}
</code></pre>
<h5 id="76&#x3001;base64&#x56FE;&#x7247;&#x4E0B;&#x8F7D;&#x529F;&#x80FD;"><a name="76&#x3001;base64&#x56FE;&#x7247;&#x4E0B;&#x8F7D;&#x529F;&#x80FD;" class="anchor-navigation-ex-anchor" href="#76&#x3001;base64&#x56FE;&#x7247;&#x4E0B;&#x8F7D;&#x529F;&#x80FD;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>76&#x3001;base64&#x56FE;&#x7247;&#x4E0B;&#x8F7D;&#x529F;&#x80FD;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> downloadFile = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">base64, fileName</span>) </span>{ <span class="hljs-comment">//base64&#x56FE;&#x7247;&#x4E0B;&#x8F7D;&#x529F;&#x80FD;</span>
  <span class="hljs-keyword">let</span> base64ToBlob = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">code</span>) </span>{
    <span class="hljs-keyword">let</span> parts = code.split(<span class="hljs-string">&apos;;base64,&apos;</span>);
    <span class="hljs-keyword">let</span> contentType = parts[<span class="hljs-number">0</span>].split(<span class="hljs-string">&apos;:&apos;</span>)[<span class="hljs-number">1</span>];
    <span class="hljs-keyword">let</span> raw = <span class="hljs-built_in">window</span>.atob(parts[<span class="hljs-number">1</span>]);
    <span class="hljs-keyword">let</span> rawLength = raw.length;
    <span class="hljs-keyword">let</span> uInt8Array = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Uint8Array</span>(rawLength);
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; rawLength; ++i) {
      uInt8Array[i] = raw.charCodeAt(i);
    }
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Blob([uInt8Array], {
      <span class="hljs-attr">type</span>: contentType
    });
  };
  <span class="hljs-keyword">let</span> aLink = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;a&apos;</span>);
  <span class="hljs-keyword">let</span> blob = base64ToBlob(base64); <span class="hljs-comment">//new Blob([content]);</span>
  <span class="hljs-keyword">let</span> evt = <span class="hljs-built_in">document</span>.createEvent(<span class="hljs-string">&quot;HTMLEvents&quot;</span>);
  evt.initEvent(<span class="hljs-string">&quot;click&quot;</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>); <span class="hljs-comment">//initEvent&#x4E0D;&#x52A0;&#x540E;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x5728;FF&#x4E0B;&#x4F1A;&#x62A5;&#x9519;  &#x4E8B;&#x4EF6;&#x7C7B;&#x578B;&#xFF0C;&#x662F;&#x5426;&#x5192;&#x6CE1;&#xFF0C;&#x662F;&#x5426;&#x963B;&#x6B62;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;</span>
  aLink.download = fileName;
  aLink.href = URL.createObjectURL(blob);
  aLink.click();
}
</code></pre>
<h5 id="77&#x3001;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;webp&#x683C;&#x5F0F;&#x56FE;&#x7247;"><a name="77&#x3001;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;webp&#x683C;&#x5F0F;&#x56FE;&#x7247;" class="anchor-navigation-ex-anchor" href="#77&#x3001;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;webp&#x683C;&#x5F0F;&#x56FE;&#x7247;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>77&#x3001;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;webP&#x683C;&#x5F0F;&#x56FE;&#x7247;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isSupportWebP = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-comment">//&#x5224;&#x65AD;&#x6D4F;&#x89C8;&#x5668;&#x662F;&#x5426;&#x652F;&#x6301;webP&#x683C;&#x5F0F;&#x56FE;&#x7247;</span>
  <span class="hljs-keyword">return</span> !![].map &amp;&amp; <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&apos;canvas&apos;</span>).toDataURL(<span class="hljs-string">&apos;image/webp&apos;</span>).indexOf(<span class="hljs-string">&apos;data:image/webp&apos;</span>) == <span class="hljs-number">0</span>;
}
</code></pre>
<h5 id="78&#x3001;url&#x53C2;&#x6570;&#x8F6C;&#x5BF9;&#x8C61;"><a name="78&#x3001;url&#x53C2;&#x6570;&#x8F6C;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#78&#x3001;url&#x53C2;&#x6570;&#x8F6C;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>78&#x3001;url&#x53C2;&#x6570;&#x8F6C;&#x5BF9;&#x8C61;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> parseQueryString = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">url</span>) </span>{ <span class="hljs-comment">//url&#x53C2;&#x6570;&#x8F6C;&#x5BF9;&#x8C61;</span>
  url = !url ? <span class="hljs-built_in">window</span>.location.href : url;
  <span class="hljs-keyword">if</span> (url.indexOf(<span class="hljs-string">&apos;?&apos;</span>) === <span class="hljs-number">-1</span>) {
    <span class="hljs-keyword">return</span> {};
  }
  <span class="hljs-keyword">let</span> search = url[<span class="hljs-number">0</span>] === <span class="hljs-string">&apos;?&apos;</span> ? url.substr(<span class="hljs-number">1</span>) : url.substring(url.lastIndexOf(<span class="hljs-string">&apos;?&apos;</span>) + <span class="hljs-number">1</span>);
  <span class="hljs-keyword">if</span> (search === <span class="hljs-string">&apos;&apos;</span>) {
    <span class="hljs-keyword">return</span> {};
  }
  search = search.split(<span class="hljs-string">&apos;&amp;&apos;</span>);
  <span class="hljs-keyword">let</span> query = {};
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; search.length; i++) {
    <span class="hljs-keyword">let</span> pair = search[i].split(<span class="hljs-string">&apos;=&apos;</span>);
    query[<span class="hljs-built_in">decodeURIComponent</span>(pair[<span class="hljs-number">0</span>])] = <span class="hljs-built_in">decodeURIComponent</span>(pair[<span class="hljs-number">1</span>] || <span class="hljs-string">&apos;&apos;</span>);
  }
  <span class="hljs-keyword">return</span> query;
}
</code></pre>
<h5 id="79&#x3001;&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x3010;&#x5BF9;&#x8C61;&#x8F6C;url&#x53C2;&#x6570;&#x3011;"><a name="79&#x3001;&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x3010;&#x5BF9;&#x8C61;&#x8F6C;url&#x53C2;&#x6570;&#x3011;" class="anchor-navigation-ex-anchor" href="#79&#x3001;&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x3010;&#x5BF9;&#x8C61;&#x8F6C;url&#x53C2;&#x6570;&#x3011;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>79&#x3001;&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x3010;&#x5BF9;&#x8C61;&#x8F6C;url&#x53C2;&#x6570;&#x3011;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> stringfyQueryString = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj</span>) </span>{ <span class="hljs-comment">//&#x5BF9;&#x8C61;&#x5E8F;&#x5217;&#x5316;&#x3010;&#x5BF9;&#x8C61;&#x8F6C;url&#x53C2;&#x6570;&#x3011;</span>
  <span class="hljs-keyword">if</span> (!obj) <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;&apos;</span>;
  <span class="hljs-keyword">let</span> pairs = [];
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> key <span class="hljs-keyword">in</span> obj) {
    <span class="hljs-keyword">let</span> value = obj[key];
    <span class="hljs-keyword">if</span> (value <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Array</span>) {
      <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; value.length; ++i) {
        pairs.push(<span class="hljs-built_in">encodeURIComponent</span>(key + <span class="hljs-string">&apos;[&apos;</span> + i + <span class="hljs-string">&apos;]&apos;</span>) + <span class="hljs-string">&apos;=&apos;</span> + <span class="hljs-built_in">encodeURIComponent</span>(value[i]));
      }
      <span class="hljs-keyword">continue</span>;
    }
    pairs.push(<span class="hljs-built_in">encodeURIComponent</span>(key) + <span class="hljs-string">&apos;=&apos;</span> + <span class="hljs-built_in">encodeURIComponent</span>(obj[key]));
  }
  <span class="hljs-keyword">return</span> pairs.join(<span class="hljs-string">&apos;&amp;&apos;</span>);
}
</code></pre>
<h5 id="80&#x3001;h5&#x8F6F;&#x952E;&#x76D8;&#x7F29;&#x56DE;&#x3001;&#x5F39;&#x8D77;&#x56DE;&#x8C03;"><a name="80&#x3001;h5&#x8F6F;&#x952E;&#x76D8;&#x7F29;&#x56DE;&#x3001;&#x5F39;&#x8D77;&#x56DE;&#x8C03;" class="anchor-navigation-ex-anchor" href="#80&#x3001;h5&#x8F6F;&#x952E;&#x76D8;&#x7F29;&#x56DE;&#x3001;&#x5F39;&#x8D77;&#x56DE;&#x8C03;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>80&#x3001;H5&#x8F6F;&#x952E;&#x76D8;&#x7F29;&#x56DE;&#x3001;&#x5F39;&#x8D77;&#x56DE;&#x8C03;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> h5Resize = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">downCb, upCb</span>) </span>{ <span class="hljs-comment">//&#x5F53;&#x8F6F;&#x4EF6;&#x952E;&#x76D8;&#x5F39;&#x8D77;&#x4F1A;&#x6539;&#x53D8;&#x5F53;&#x524D; window.innerHeight&#xFF0C;&#x76D1;&#x542C;&#x8FD9;&#x4E2A;&#x503C;&#x53D8;&#x5316; [downCb &#x5F53;&#x8F6F;&#x952E;&#x76D8;&#x5F39;&#x8D77;&#x540E;&#xFF0C;&#x7F29;&#x56DE;&#x7684;&#x56DE;&#x8C03;,upCb &#x5F53;&#x8F6F;&#x952E;&#x76D8;&#x5F39;&#x8D77;&#x7684;&#x56DE;&#x8C03;]</span>
  <span class="hljs-keyword">var</span> clientHeight = <span class="hljs-built_in">window</span>.innerHeight;
  downCb = <span class="hljs-keyword">typeof</span> downCb === <span class="hljs-string">&apos;function&apos;</span> ? downCb : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}
  upCb = <span class="hljs-keyword">typeof</span> upCb === <span class="hljs-string">&apos;function&apos;</span> ? upCb : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{}
  <span class="hljs-built_in">window</span>.addEventListener(<span class="hljs-string">&apos;resize&apos;</span>, () =&gt; {
    <span class="hljs-keyword">var</span> height = <span class="hljs-built_in">window</span>.innerHeight;
    <span class="hljs-keyword">if</span> (height === clientHeight) {
      downCb();
    }
    <span class="hljs-keyword">if</span> (height &lt; clientHeight) {
      upCb();
    }
  });
}
</code></pre>
<h5 id="81&#x3001;&#x51FD;&#x6570;&#x9632;&#x6296;"><a name="81&#x3001;&#x51FD;&#x6570;&#x9632;&#x6296;" class="anchor-navigation-ex-anchor" href="#81&#x3001;&#x51FD;&#x6570;&#x9632;&#x6296;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>81&#x3001;&#x51FD;&#x6570;&#x9632;&#x6296;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> debounce = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">func, wait, immediate</span>) </span>{ <span class="hljs-comment">//&#x51FD;&#x6570;&#x9632;&#x6296;[func &#x51FD;&#x6570;,wait &#x5EF6;&#x8FDF;&#x6267;&#x884C;&#x6BEB;&#x79D2;&#x6570;,immediate true &#x8868;&#x7ACB;&#x5373;&#x6267;&#x884C;,false &#x8868;&#x975E;&#x7ACB;&#x5373;&#x6267;&#x884C;,&#x7ACB;&#x5373;&#x6267;&#x884C;&#x662F;&#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x540E;&#x51FD;&#x6570;&#x4F1A;&#x7ACB;&#x5373;&#x6267;&#x884C;&#xFF0C;&#x7136;&#x540E;n&#x79D2;&#x5185;&#x4E0D;&#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x624D;&#x80FD;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x51FD;&#x6570;&#x7684;&#x6548;&#x679C;]</span>
  <span class="hljs-keyword">let</span> timeout;
  <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> context = <span class="hljs-keyword">this</span>;
    <span class="hljs-keyword">let</span> args = <span class="hljs-built_in">arguments</span>;
    <span class="hljs-keyword">if</span> (timeout) clearTimeout(timeout);
    <span class="hljs-keyword">if</span> (immediate) {
      <span class="hljs-keyword">var</span> callNow = !timeout;
      timeout = setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {
        timeout = <span class="hljs-literal">null</span>;
      }, wait)
      <span class="hljs-keyword">if</span> (callNow) func.apply(context, args)
    } <span class="hljs-keyword">else</span> {
      timeout = setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
        func.apply(context, args)
      }, wait);
    }
  }
}
</code></pre>
<h5 id="82&#x3001;&#x51FD;&#x6570;&#x8282;&#x6D41;"><a name="82&#x3001;&#x51FD;&#x6570;&#x8282;&#x6D41;" class="anchor-navigation-ex-anchor" href="#82&#x3001;&#x51FD;&#x6570;&#x8282;&#x6D41;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>82&#x3001;&#x51FD;&#x6570;&#x8282;&#x6D41;</strong></h5>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> throttle = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">func, wait ,type</span>) </span>{ <span class="hljs-comment">//&#x51FD;&#x6570;&#x8282;&#x6D41; [func &#x51FD;&#x6570; wait &#x5EF6;&#x8FDF;&#x6267;&#x884C;&#x6BEB;&#x79D2;&#x6570; type 1 &#x8868;&#x65F6;&#x95F4;&#x6233;&#x7248;&#xFF0C;2 &#x8868;&#x5B9A;&#x65F6;&#x5668;&#x7248;]</span>
    <span class="hljs-keyword">if</span>(type===<span class="hljs-number">1</span>){
        <span class="hljs-keyword">let</span> previous = <span class="hljs-number">0</span>;
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(type===<span class="hljs-number">2</span>){
        <span class="hljs-keyword">let</span> timeout;
    }
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">let</span> context = <span class="hljs-keyword">this</span>;
        <span class="hljs-keyword">let</span> args = <span class="hljs-built_in">arguments</span>;
        <span class="hljs-keyword">if</span>(type===<span class="hljs-number">1</span>){
            <span class="hljs-keyword">let</span> now = <span class="hljs-built_in">Date</span>.now();
            <span class="hljs-keyword">if</span> (now - previous &gt; wait) {
                func.apply(context, args);
                previous = now;
            }
        }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(type===<span class="hljs-number">2</span>){
            <span class="hljs-keyword">if</span> (!timeout) {
                timeout = setTimeout(<span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> {
                    timeout = <span class="hljs-literal">null</span>;
                    func.apply(context, args)
                }, wait)
            }
        }
    }
}
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2021-12-28 12:20:24
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="在 JavaScript 中交换值的 10 种方法.html" class="navigation navigation-prev " aria-label="Previous page: 在 JavaScript 中交换值的 10 种方法">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="异步神器Async-await介绍与填坑.html" class="navigation navigation-next " aria-label="Next page: 异步神器Async Await介绍与填坑">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"常用的前端JavaScript方法封装","level":"4.16","depth":1,"next":{"title":"异步神器Async Await介绍与填坑","level":"4.17","depth":1,"path":"javaScript/异步神器Async-await介绍与填坑.md","ref":"javaScript/异步神器Async-await介绍与填坑.md","articles":[]},"previous":{"title":"在 JavaScript 中交换值的 10 种方法","level":"4.15","depth":1,"path":"javaScript/在 JavaScript 中交换值的 10 种方法.md","ref":"javaScript/在 JavaScript 中交换值的 10 种方法.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/常用的前端JavaScript方法封装.md","mtime":"2021-12-28T04:20:24.086Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

